psd: github.com/oov/psd Index | Files | Directories

package psd

import "github.com/oov/psd"

Index

Package Files

blendmode.go colormode.go compress.go compress_other.go imageres.go layer.go picker.go psd.go util.go

Constants

const (
    BlendModePassThrough  = BlendMode("pass")
    BlendModeNormal       = BlendMode("norm")
    BlendModeDissolve     = BlendMode("diss")
    BlendModeDarken       = BlendMode("dark")
    BlendModeMultiply     = BlendMode("mul ")
    BlendModeColorBurn    = BlendMode("idiv")
    BlendModeLinearBurn   = BlendMode("lbrn")
    BlendModeDarkerColor  = BlendMode("dkCl")
    BlendModeLighten      = BlendMode("lite")
    BlendModeScreen       = BlendMode("scrn")
    BlendModeColorDodge   = BlendMode("div ")
    BlendModeLinearDodge  = BlendMode("lddg")
    BlendModeLighterColor = BlendMode("lgCl")
    BlendModeOverlay      = BlendMode("over")
    BlendModeSoftLight    = BlendMode("sLit")
    BlendModeHardLight    = BlendMode("hLit")
    BlendModeVividLight   = BlendMode("vLit")
    BlendModeLinearLight  = BlendMode("lLit")
    BlendModePinLight     = BlendMode("pLit")
    BlendModeHardMix      = BlendMode("hMix")
    BlendModeDifference   = BlendMode("diff")
    BlendModeExclusion    = BlendMode("smud")
    BlendModeSubtract     = BlendMode("fsub")
    BlendModeDivide       = BlendMode("fdiv")
    BlendModeHue          = BlendMode("hue ")
    BlendModeSaturation   = BlendMode("sat ")
    BlendModeColor        = BlendMode("colr")
    BlendModeLuminosity   = BlendMode("lum ")
)

These blend modes are defined in this document.

http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577409_13084

const (
    ColorModeBitmap       = ColorMode(0)
    ColorModeGrayscale    = ColorMode(1)
    ColorModeIndexed      = ColorMode(2)
    ColorModeRGB          = ColorMode(3)
    ColorModeCMYK         = ColorMode(4)
    ColorModeMultichannel = ColorMode(7)
    ColorModeDuotone      = ColorMode(8)
    ColorModeLab          = ColorMode(9)
)

These color modes are defined in this document.

http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577409_19840

const (
    CompressionMethodRaw                  = CompressionMethod(0)
    CompressionMethodRLE                  = CompressionMethod(1)
    CompressionMethodZIPWithoutPrediction = CompressionMethod(2)
    CompressionMethodZIPWithPrediction    = CompressionMethod(3)
)

These compression methods are defined in this document.

http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577409_pgfId-1054855

const (
    AdditionalInfoKeyLayerInfo              = AdditionalInfoKey("Layr")
    AdditionalInfoKeyLayerInfo16            = AdditionalInfoKey("Lr16")
    AdditionalInfoKeyLayerInfo32            = AdditionalInfoKey("Lr32")
    AdditionalInfoKeyUnicodeLayerName       = AdditionalInfoKey("luni")
    AdditionalInfoKeyBlendClippingElements  = AdditionalInfoKey("clbl")
    AdditionalInfoKeySectionDividerSetting  = AdditionalInfoKey("lsct")
    AdditionalInfoKeySectionDividerSetting2 = AdditionalInfoKey("lsdk")
)

These keys are defined in this document.

http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577409_71546

Variables

var Debug logger

Debug is useful for debugging.

You can use by performing the following steps.

psd.Debug = log.New(os.Stdout, "psd: ", log.Lshortfile)

type AdditionalInfoKey Uses

type AdditionalInfoKey string

AdditionalInfoKey represents the key of the additional layer information.

func (AdditionalInfoKey) LenSize Uses

func (a AdditionalInfoKey) LenSize(largeDocument bool) int

LenSize returns bytes of the length for this key.

type BlendMode Uses

type BlendMode string

BlendMode represents the blend mode.

func (BlendMode) String Uses

func (bm BlendMode) String() string

String implements fmt.Stringer interface.

The return value respects blend name that is described in "Compositing and Blending Level 1"(https://www.w3.org/TR/compositing-1/#blending).

type Channel Uses

type Channel struct {
    // Data is uncompressed channel image data.
    Data   []byte
    Picker image.Image
}

Channel represents a channel of the color.

type ColorMode Uses

type ColorMode int16

ColorMode represents color mode that is used in psd file.

func (ColorMode) Channels Uses

func (c ColorMode) Channels() int

Channels returns the number of channels for the color mode. The return value is not including alpha channel.

type CompressionMethod Uses

type CompressionMethod int16

CompressionMethod represents compression method that is used in psd file.

func (CompressionMethod) Decode Uses

func (cm CompressionMethod) Decode(dest []byte, r io.Reader, sizeHint int64, rect image.Rectangle, depth int, channels int, large bool) (read int, err error)

Decode decodes the compressed image data from r.

You can pass 0 to sizeHint if unknown, but in this case may read more data than necessary from r.

type Config Uses

type Config struct {
    Version       int
    Rect          image.Rectangle
    Channels      int
    Depth         int // 1 or 8 or 16 or 32
    ColorMode     ColorMode
    ColorModeData []byte
    Res           map[int]ImageResource
}

Config represents Photoshop image file configuration.

func DecodeConfig Uses

func DecodeConfig(r io.Reader) (cfg Config, read int, err error)

DecodeConfig returns the color model and dimensions of a image without decoding the entire image.

func (*Config) PSB Uses

func (cfg *Config) PSB() bool

PSB returns whether image is large document format.

func (*Config) Palette Uses

func (cfg *Config) Palette() color.Palette

Palette returns Palette if any.

type DecodeOptions Uses

type DecodeOptions struct {
    SkipLayerImage   bool
    SkipMergedImage  bool
    ConfigLoaded     func(cfg Config) error
    LayerImageLoaded func(layer *Layer, index int, total int)
}

DecodeOptions are the decoding options.

type ImageResource Uses

type ImageResource struct {
    Name string
    Data []byte
}

ImageResource represents the image resource that is used in psd file.

type Layer Uses

type Layer struct {
    SeqID int

    Name        string
    UnicodeName string
    MBCSName    string

    Rect image.Rectangle
    // Channel key is the channel ID.
    // 	0 = red, 1 = green, etc.
    // 	-1 = transparency mask
    // 	-2 = user supplied layer mask
    // 	-3 = real user supplied layer mask
    //         (when both a user mask and a vector mask are present)
    Channel               map[int]Channel
    BlendMode             BlendMode
    Opacity               uint8
    Clipping              bool
    BlendClippedElements  bool
    Flags                 uint8
    Mask                  Mask
    Picker                image.Image
    AdditionalLayerInfo   map[AdditionalInfoKey][]byte
    SectionDividerSetting struct {
        Type      int
        BlendMode BlendMode
        SubType   int
    }

    Layer []Layer
}

Layer represents layer.

func (*Layer) Folder Uses

func (l *Layer) Folder() bool

Folder returns whether the layer is folder(group layer).

func (*Layer) FolderIsOpen Uses

func (l *Layer) FolderIsOpen() bool

FolderIsOpen returns whether the folder is opened when layer is folder.

func (*Layer) HasImage Uses

func (l *Layer) HasImage() bool

HasImage returns whether the layer has an image data.

func (*Layer) String Uses

func (l *Layer) String() string

func (*Layer) TransparencyProtected Uses

func (l *Layer) TransparencyProtected() bool

TransparencyProtected returns whether the layer's transparency being protected.

func (*Layer) Visible Uses

func (l *Layer) Visible() bool

Visible returns whether the layer is visible.

type Mask Uses

type Mask struct {
    Rect         image.Rectangle
    DefaultColor int
    Flags        int

    RealRect            image.Rectangle
    RealBackgroundColor int
    RealFlags           int

    UserMaskDensity   int
    UserMaskFeather   float64
    VectorMaskDensity int
    VectorMaskFeather float64
}

Mask represents layer mask and vector mask.

func (*Mask) Enabled Uses

func (m *Mask) Enabled() bool

Enabled returns whether the mask is enabled.

func (*Mask) RealEnabled Uses

func (m *Mask) RealEnabled() bool

RealEnabled returns whether the user real mask is enabled.

type PSD Uses

type PSD struct {
    Config             Config
    Channel            map[int]Channel
    Layer              []Layer
    AdditinalLayerInfo map[AdditionalInfoKey][]byte
    // Data is uncompressed merged image data.
    Data   []byte
    Picker image.Image
}

PSD represents Photoshop image file.

func Decode Uses

func Decode(r io.Reader, o *DecodeOptions) (psd *PSD, read int, err error)

Decode reads a image from r and returns it. Default parameters are used if a nil *DecodeOptions is passed.

Directories

PathSynopsis
blendCode generated by genrgba2nrgba.go.
color
compositePackage composite implements PSD image compositor.
psdexporter

Package psd imports 12 packages (graph) and is imported by 5 packages. Updated 2020-12-03. Refresh now. Tools for package owners.