psd_tools.api.layers

Layer module.

Artboard

class psd_tools.api.layers.Artboard(*args)[source]

Artboard is a special kind of group that has a pre-defined viewbox.

Example:

artboard = psd[1]
image = artboard.compose()
bbox

(left, top, right, bottom) tuple.

blend_mode

Blend mode of this layer. Writable.

Example:

from psd_tools.constants import BlendMode
if layer.blend_mode == BlendMode.NORMAL:
    layer.blend_mode = BlendMode.SCREEN
Returns:BlendMode.
bottom

Bottom coordinate.

Returns:int
clip_layers

Clip layers associated with this layer.

To compose clipping layers:

from psd_tools import compose
clip_mask = compose(layer.clip_layers)
Returns:list of layers
compose(bbox=None, **kwargs)[source]

Compose the artboard.

See compose() for available extra arguments.

Parameters:bbox – Viewport tuple (left, top, right, bottom).
Returns:PIL.Image, or None if there is no pixel.
descendants(include_clip=True)

Return a generator to iterate over all descendant layers.

Example:

# Iterate over all layers
for layer in psd.descendants():
    print(layer)

# Iterate over all layers in reverse order
for layer in reversed(list(psd.descendants())):
    print(layer)
Parameters:include_clip – include clipping layers.
effects

Layer effects.

Returns:Effects
static extract_bbox(layers)

Returns a bounding box for layers or (0, 0, 0, 0) if the layers have no bounding box.

has_clip_layers()

Returns True if the layer has associated clipping.

Returns:bool
has_effects()

Returns True if the layer has effects.

Returns:bool
has_mask()

Returns True if the layer has a mask.

Returns:bool
has_origination()

Returns True if the layer has live shape properties.

Returns:bool
has_pixels()

Returns True if the layer has associated pixels. When this is True, topil method returns PIL.Image.

Returns:bool
has_stroke()

Returns True if the shape has a stroke.

has_vector_mask()

Returns True if the layer has a vector mask.

Returns:bool
height

Height of the layer.

Returns:int
is_group()

Return True if the layer is a group.

Returns:bool
is_visible()

Layer visibility. Takes group visibility in account.

Returns:bool
kind

Kind of this layer, such as group, pixel, shape, type, smartobject, or psdimage. Class name without layer suffix.

Returns:str
layer_id

Layer ID.

Returns:int layer id. if the layer is not assigned an id, -1.
left

Left coordinate. Writable.

Returns:int
mask

Returns mask associated with this layer.

Returns:Mask or None
name

Layer name. Writable.

Returns:str
offset

(left, top) tuple. Writable.

Returns:tuple
opacity

Opacity of this layer in [0, 255] range. Writable.

Returns:int
origination

Property for a list of live shapes or a line.

Some of the vector masks have associated live shape properties, that are Photoshop feature to handle primitive shapes such as a rectangle, an ellipse, or a line. Vector masks without live shape properties are plain path objects.

See psd_tools.api.shape.

Returns:List of Invalidated, Rectangle, RoundedRectangle, Ellipse, or Line.
parent

Parent of this layer.

right

Right coordinate.

Returns:int
size

(width, height) tuple.

Returns:tuple
stroke

Property for strokes.

tagged_blocks

Layer tagged blocks that is a dict-like container of settings.

See psd_tools.constants.Tag for available keys.

Returns:TaggedBlocks or None.

Example:

from psd_tools.constants import Tag
metadata = layer.tagged_blocks.get_data(Tag.METADATA_SETTING)
top

Top coordinate. Writable.

Returns:int
topil(channel=None, **kwargs)

Get PIL Image of the layer.

Parameters:channel – Which channel to return; e.g., 0 for ‘R’ channel in RGB image. See ChannelID. When None, the method returns all the channels supported by PIL modes.
Returns:PIL.Image, or None if the layer has no pixels.

Example:

from psd_tools.constants import ChannelID

image = layer.topil()
red = layer.topil(ChannelID.CHANNEL_0)
alpha = layer.topil(ChannelID.TRANSPARENCY_MASK)

Note

Not all of the PSD image modes are supported in PIL.Image. For example, ‘CMYK’ mode cannot include alpha channel in PIL. In this case, topil drops alpha channel.

vector_mask

Returns vector mask associated with this layer.

Returns:VectorMask or None
visible

Layer visibility. Doesn’t take group visibility in account. Writable.

Returns:bool
width

Width of the layer.

Returns:int

Group

class psd_tools.api.layers.Group(*args)[source]

Group of layers.

Example:

group = psd[1]
for layer in group:
    if layer.kind == 'pixel':
        print(layer.name)
bbox

(left, top, right, bottom) tuple.

blend_mode

Blend mode of this layer. Writable.

Example:

from psd_tools.constants import BlendMode
if layer.blend_mode == BlendMode.NORMAL:
    layer.blend_mode = BlendMode.SCREEN
Returns:BlendMode.
clip_layers

Clip layers associated with this layer.

To compose clipping layers:

from psd_tools import compose
clip_mask = compose(layer.clip_layers)
Returns:list of layers
compose(**kwargs)

Compose layer and masks (mask, vector mask, and clipping layers).

Returns:PIL Image object, or None if the layer has no pixels.
descendants(include_clip=True)

Return a generator to iterate over all descendant layers.

Example:

# Iterate over all layers
for layer in psd.descendants():
    print(layer)

# Iterate over all layers in reverse order
for layer in reversed(list(psd.descendants())):
    print(layer)
Parameters:include_clip – include clipping layers.
effects

Layer effects.

Returns:Effects
static extract_bbox(layers)[source]

Returns a bounding box for layers or (0, 0, 0, 0) if the layers have no bounding box.

has_clip_layers()

Returns True if the layer has associated clipping.

Returns:bool
has_effects()

Returns True if the layer has effects.

Returns:bool
has_mask()

Returns True if the layer has a mask.

Returns:bool
has_origination()

Returns True if the layer has live shape properties.

Returns:bool
has_pixels()

Returns True if the layer has associated pixels. When this is True, topil method returns PIL.Image.

Returns:bool
has_stroke()

Returns True if the shape has a stroke.

has_vector_mask()

Returns True if the layer has a vector mask.

Returns:bool
height

Height of the layer.

Returns:int
is_group()

Return True if the layer is a group.

Returns:bool
is_visible()

Layer visibility. Takes group visibility in account.

Returns:bool
kind

Kind of this layer, such as group, pixel, shape, type, smartobject, or psdimage. Class name without layer suffix.

Returns:str
layer_id

Layer ID.

Returns:int layer id. if the layer is not assigned an id, -1.
mask

Returns mask associated with this layer.

Returns:Mask or None
name

Layer name. Writable.

Returns:str
offset

(left, top) tuple. Writable.

Returns:tuple
opacity

Opacity of this layer in [0, 255] range. Writable.

Returns:int
origination

Property for a list of live shapes or a line.

Some of the vector masks have associated live shape properties, that are Photoshop feature to handle primitive shapes such as a rectangle, an ellipse, or a line. Vector masks without live shape properties are plain path objects.

See psd_tools.api.shape.

Returns:List of Invalidated, Rectangle, RoundedRectangle, Ellipse, or Line.
parent

Parent of this layer.

size

(width, height) tuple.

Returns:tuple
stroke

Property for strokes.

tagged_blocks

Layer tagged blocks that is a dict-like container of settings.

See psd_tools.constants.Tag for available keys.

Returns:TaggedBlocks or None.

Example:

from psd_tools.constants import Tag
metadata = layer.tagged_blocks.get_data(Tag.METADATA_SETTING)
topil(channel=None, **kwargs)

Get PIL Image of the layer.

Parameters:channel – Which channel to return; e.g., 0 for ‘R’ channel in RGB image. See ChannelID. When None, the method returns all the channels supported by PIL modes.
Returns:PIL.Image, or None if the layer has no pixels.

Example:

from psd_tools.constants import ChannelID

image = layer.topil()
red = layer.topil(ChannelID.CHANNEL_0)
alpha = layer.topil(ChannelID.TRANSPARENCY_MASK)

Note

Not all of the PSD image modes are supported in PIL.Image. For example, ‘CMYK’ mode cannot include alpha channel in PIL. In this case, topil drops alpha channel.

vector_mask

Returns vector mask associated with this layer.

Returns:VectorMask or None
visible

Layer visibility. Doesn’t take group visibility in account. Writable.

Returns:bool
width

Width of the layer.

Returns:int

PixelLayer

class psd_tools.api.layers.PixelLayer(psd, record, channels, parent)[source]

Layer that has rasterized image in pixels.

Example:

assert layer.kind == 'pixel':
image = layer.topil()
image.save('layer.png')

composed_image = layer.compose()
composed_image.save('composed-layer.png')
bbox

(left, top, right, bottom) tuple.

blend_mode

Blend mode of this layer. Writable.

Example:

from psd_tools.constants import BlendMode
if layer.blend_mode == BlendMode.NORMAL:
    layer.blend_mode = BlendMode.SCREEN
Returns:BlendMode.
bottom

Bottom coordinate.

Returns:int
clip_layers

Clip layers associated with this layer.

To compose clipping layers:

from psd_tools import compose
clip_mask = compose(layer.clip_layers)
Returns:list of layers
compose(bbox=None, **kwargs)

Compose layer and masks (mask, vector mask, and clipping layers).

Note that the resulting image size is not necessarily equal to the layer size due to different mask dimensions. The offset of the composed image is stored at .info[‘offset’] attribute of PIL.Image.

Parameters:bbox – Viewport bounding box specified by (x1, y1, x2, y2) tuple.
Returns:PIL.Image, or None if the layer has no pixel.
effects

Layer effects.

Returns:Effects
has_clip_layers()

Returns True if the layer has associated clipping.

Returns:bool
has_effects()

Returns True if the layer has effects.

Returns:bool
has_mask()

Returns True if the layer has a mask.

Returns:bool
has_origination()

Returns True if the layer has live shape properties.

Returns:bool
has_pixels()

Returns True if the layer has associated pixels. When this is True, topil method returns PIL.Image.

Returns:bool
has_stroke()

Returns True if the shape has a stroke.

has_vector_mask()

Returns True if the layer has a vector mask.

Returns:bool
height

Height of the layer.

Returns:int
is_group()

Return True if the layer is a group.

Returns:bool
is_visible()

Layer visibility. Takes group visibility in account.

Returns:bool
kind

Kind of this layer, such as group, pixel, shape, type, smartobject, or psdimage. Class name without layer suffix.

Returns:str
layer_id

Layer ID.

Returns:int layer id. if the layer is not assigned an id, -1.
left

Left coordinate. Writable.

Returns:int
mask

Returns mask associated with this layer.

Returns:Mask or None
name

Layer name. Writable.

Returns:str
offset

(left, top) tuple. Writable.

Returns:tuple
opacity

Opacity of this layer in [0, 255] range. Writable.

Returns:int
origination

Property for a list of live shapes or a line.

Some of the vector masks have associated live shape properties, that are Photoshop feature to handle primitive shapes such as a rectangle, an ellipse, or a line. Vector masks without live shape properties are plain path objects.

See psd_tools.api.shape.

Returns:List of Invalidated, Rectangle, RoundedRectangle, Ellipse, or Line.
parent

Parent of this layer.

right

Right coordinate.

Returns:int
size

(width, height) tuple.

Returns:tuple
stroke

Property for strokes.

tagged_blocks

Layer tagged blocks that is a dict-like container of settings.

See psd_tools.constants.Tag for available keys.

Returns:TaggedBlocks or None.

Example:

from psd_tools.constants import Tag
metadata = layer.tagged_blocks.get_data(Tag.METADATA_SETTING)
top

Top coordinate. Writable.

Returns:int
topil(channel=None, **kwargs)

Get PIL Image of the layer.

Parameters:channel – Which channel to return; e.g., 0 for ‘R’ channel in RGB image. See ChannelID. When None, the method returns all the channels supported by PIL modes.
Returns:PIL.Image, or None if the layer has no pixels.

Example:

from psd_tools.constants import ChannelID

image = layer.topil()
red = layer.topil(ChannelID.CHANNEL_0)
alpha = layer.topil(ChannelID.TRANSPARENCY_MASK)

Note

Not all of the PSD image modes are supported in PIL.Image. For example, ‘CMYK’ mode cannot include alpha channel in PIL. In this case, topil drops alpha channel.

vector_mask

Returns vector mask associated with this layer.

Returns:VectorMask or None
visible

Layer visibility. Doesn’t take group visibility in account. Writable.

Returns:bool
width

Width of the layer.

Returns:int

ShapeLayer

class psd_tools.api.layers.ShapeLayer(psd, record, channels, parent)[source]

Layer that has drawing in vector mask.

bbox

(left, top, right, bottom) tuple.

blend_mode

Blend mode of this layer. Writable.

Example:

from psd_tools.constants import BlendMode
if layer.blend_mode == BlendMode.NORMAL:
    layer.blend_mode = BlendMode.SCREEN
Returns:BlendMode.
bottom

Bottom coordinate.

Returns:int
clip_layers

Clip layers associated with this layer.

To compose clipping layers:

from psd_tools import compose
clip_mask = compose(layer.clip_layers)
Returns:list of layers
compose(bbox=None, **kwargs)

Compose layer and masks (mask, vector mask, and clipping layers).

Note that the resulting image size is not necessarily equal to the layer size due to different mask dimensions. The offset of the composed image is stored at .info[‘offset’] attribute of PIL.Image.

Parameters:bbox – Viewport bounding box specified by (x1, y1, x2, y2) tuple.
Returns:PIL.Image, or None if the layer has no pixel.
effects

Layer effects.

Returns:Effects
has_clip_layers()

Returns True if the layer has associated clipping.

Returns:bool
has_effects()

Returns True if the layer has effects.

Returns:bool
has_mask()

Returns True if the layer has a mask.

Returns:bool
has_origination()

Returns True if the layer has live shape properties.

Returns:bool
has_pixels()

Returns True if the layer has associated pixels. When this is True, topil method returns PIL.Image.

Returns:bool
has_stroke()

Returns True if the shape has a stroke.

has_vector_mask()

Returns True if the layer has a vector mask.

Returns:bool
height

Height of the layer.

Returns:int
is_group()

Return True if the layer is a group.

Returns:bool
is_visible()

Layer visibility. Takes group visibility in account.

Returns:bool
kind

Kind of this layer, such as group, pixel, shape, type, smartobject, or psdimage. Class name without layer suffix.

Returns:str
layer_id

Layer ID.

Returns:int layer id. if the layer is not assigned an id, -1.
left

Left coordinate. Writable.

Returns:int
mask

Returns mask associated with this layer.

Returns:Mask or None
name

Layer name. Writable.

Returns:str
offset

(left, top) tuple. Writable.

Returns:tuple
opacity

Opacity of this layer in [0, 255] range. Writable.

Returns:int
origination

Property for a list of live shapes or a line.

Some of the vector masks have associated live shape properties, that are Photoshop feature to handle primitive shapes such as a rectangle, an ellipse, or a line. Vector masks without live shape properties are plain path objects.

See psd_tools.api.shape.

Returns:List of Invalidated, Rectangle, RoundedRectangle, Ellipse, or Line.
parent

Parent of this layer.

right

Right coordinate.

Returns:int
size

(width, height) tuple.

Returns:tuple
stroke

Property for strokes.

tagged_blocks

Layer tagged blocks that is a dict-like container of settings.

See psd_tools.constants.Tag for available keys.

Returns:TaggedBlocks or None.

Example:

from psd_tools.constants import Tag
metadata = layer.tagged_blocks.get_data(Tag.METADATA_SETTING)
top

Top coordinate. Writable.

Returns:int
topil(channel=None, **kwargs)

Get PIL Image of the layer.

Parameters:channel – Which channel to return; e.g., 0 for ‘R’ channel in RGB image. See ChannelID. When None, the method returns all the channels supported by PIL modes.
Returns:PIL.Image, or None if the layer has no pixels.

Example:

from psd_tools.constants import ChannelID

image = layer.topil()
red = layer.topil(ChannelID.CHANNEL_0)
alpha = layer.topil(ChannelID.TRANSPARENCY_MASK)

Note

Not all of the PSD image modes are supported in PIL.Image. For example, ‘CMYK’ mode cannot include alpha channel in PIL. In this case, topil drops alpha channel.

vector_mask

Returns vector mask associated with this layer.

Returns:VectorMask or None
visible

Layer visibility. Doesn’t take group visibility in account. Writable.

Returns:bool
width

Width of the layer.

Returns:int

SmartObjectLayer

class psd_tools.api.layers.SmartObjectLayer(psd, record, channels, parent)[source]

Layer that inserts external data.

Use smart_object attribute to get the external data. See SmartObject.

Example:

import io
if layer.smart_object.filetype == 'jpg':
    image = Image.open(io.BytesIO(layer.smart_object.data))
bbox

(left, top, right, bottom) tuple.

blend_mode

Blend mode of this layer. Writable.

Example:

from psd_tools.constants import BlendMode
if layer.blend_mode == BlendMode.NORMAL:
    layer.blend_mode = BlendMode.SCREEN
Returns:BlendMode.
bottom

Bottom coordinate.

Returns:int
clip_layers

Clip layers associated with this layer.

To compose clipping layers:

from psd_tools import compose
clip_mask = compose(layer.clip_layers)
Returns:list of layers
compose(bbox=None, **kwargs)

Compose layer and masks (mask, vector mask, and clipping layers).

Note that the resulting image size is not necessarily equal to the layer size due to different mask dimensions. The offset of the composed image is stored at .info[‘offset’] attribute of PIL.Image.

Parameters:bbox – Viewport bounding box specified by (x1, y1, x2, y2) tuple.
Returns:PIL.Image, or None if the layer has no pixel.
effects

Layer effects.

Returns:Effects
has_clip_layers()

Returns True if the layer has associated clipping.

Returns:bool
has_effects()

Returns True if the layer has effects.

Returns:bool
has_mask()

Returns True if the layer has a mask.

Returns:bool
has_origination()

Returns True if the layer has live shape properties.

Returns:bool
has_pixels()

Returns True if the layer has associated pixels. When this is True, topil method returns PIL.Image.

Returns:bool
has_stroke()

Returns True if the shape has a stroke.

has_vector_mask()

Returns True if the layer has a vector mask.

Returns:bool
height

Height of the layer.

Returns:int
is_group()

Return True if the layer is a group.

Returns:bool
is_visible()

Layer visibility. Takes group visibility in account.

Returns:bool
kind

Kind of this layer, such as group, pixel, shape, type, smartobject, or psdimage. Class name without layer suffix.

Returns:str
layer_id

Layer ID.

Returns:int layer id. if the layer is not assigned an id, -1.
left

Left coordinate. Writable.

Returns:int
mask

Returns mask associated with this layer.

Returns:Mask or None
name

Layer name. Writable.

Returns:str
offset

(left, top) tuple. Writable.

Returns:tuple
opacity

Opacity of this layer in [0, 255] range. Writable.

Returns:int
origination

Property for a list of live shapes or a line.

Some of the vector masks have associated live shape properties, that are Photoshop feature to handle primitive shapes such as a rectangle, an ellipse, or a line. Vector masks without live shape properties are plain path objects.

See psd_tools.api.shape.

Returns:List of Invalidated, Rectangle, RoundedRectangle, Ellipse, or Line.
parent

Parent of this layer.

right

Right coordinate.

Returns:int
size

(width, height) tuple.

Returns:tuple
smart_object

Associated smart object.

Returns:SmartObject.
stroke

Property for strokes.

tagged_blocks

Layer tagged blocks that is a dict-like container of settings.

See psd_tools.constants.Tag for available keys.

Returns:TaggedBlocks or None.

Example:

from psd_tools.constants import Tag
metadata = layer.tagged_blocks.get_data(Tag.METADATA_SETTING)
top

Top coordinate. Writable.

Returns:int
topil(channel=None, **kwargs)

Get PIL Image of the layer.

Parameters:channel – Which channel to return; e.g., 0 for ‘R’ channel in RGB image. See ChannelID. When None, the method returns all the channels supported by PIL modes.
Returns:PIL.Image, or None if the layer has no pixels.

Example:

from psd_tools.constants import ChannelID

image = layer.topil()
red = layer.topil(ChannelID.CHANNEL_0)
alpha = layer.topil(ChannelID.TRANSPARENCY_MASK)

Note

Not all of the PSD image modes are supported in PIL.Image. For example, ‘CMYK’ mode cannot include alpha channel in PIL. In this case, topil drops alpha channel.

vector_mask

Returns vector mask associated with this layer.

Returns:VectorMask or None
visible

Layer visibility. Doesn’t take group visibility in account. Writable.

Returns:bool
width

Width of the layer.

Returns:int

TypeLayer

class psd_tools.api.layers.TypeLayer(*args)[source]

Layer that has text and styling information for fonts or paragraphs.

Text is accessible at text property. Styling information for paragraphs is in engine_dict. Document styling information such as font list is is resource_dict.

Currently, textual information is read-only.

Example:

if layer.kind == 'type':
    print(layer.text)
    print(layer.engine_dict['StyleRun'])

    # Extract font for each substring in the text.
    text = layer.engine_dict['Editor']['Text'].value
    fontset = layer.resource_dict['FontSet']
    runlength = layer.engine_dict['StyleRun']['RunLengthArray']
    rundata = layer.engine_dict['StyleRun']['RunArray']
    index = 0
    for length, style in zip(runlength, rundata):
        substring = text[index:index + length]
        stylesheet = style['StyleSheet']['StyleSheetData']
        font = fontset[stylesheet['Font']]
        print('%r gets %s' % (substring, font))
        index += length
bbox

(left, top, right, bottom) tuple.

blend_mode

Blend mode of this layer. Writable.

Example:

from psd_tools.constants import BlendMode
if layer.blend_mode == BlendMode.NORMAL:
    layer.blend_mode = BlendMode.SCREEN
Returns:BlendMode.
bottom

Bottom coordinate.

Returns:int
clip_layers

Clip layers associated with this layer.

To compose clipping layers:

from psd_tools import compose
clip_mask = compose(layer.clip_layers)
Returns:list of layers
compose(bbox=None, **kwargs)

Compose layer and masks (mask, vector mask, and clipping layers).

Note that the resulting image size is not necessarily equal to the layer size due to different mask dimensions. The offset of the composed image is stored at .info[‘offset’] attribute of PIL.Image.

Parameters:bbox – Viewport bounding box specified by (x1, y1, x2, y2) tuple.
Returns:PIL.Image, or None if the layer has no pixel.
document_resources

Resource set relevant to the document.

effects

Layer effects.

Returns:Effects
engine_dict

Styling information dict.

has_clip_layers()

Returns True if the layer has associated clipping.

Returns:bool
has_effects()

Returns True if the layer has effects.

Returns:bool
has_mask()

Returns True if the layer has a mask.

Returns:bool
has_origination()

Returns True if the layer has live shape properties.

Returns:bool
has_pixels()

Returns True if the layer has associated pixels. When this is True, topil method returns PIL.Image.

Returns:bool
has_stroke()

Returns True if the shape has a stroke.

has_vector_mask()

Returns True if the layer has a vector mask.

Returns:bool
height

Height of the layer.

Returns:int
is_group()

Return True if the layer is a group.

Returns:bool
is_visible()

Layer visibility. Takes group visibility in account.

Returns:bool
kind

Kind of this layer, such as group, pixel, shape, type, smartobject, or psdimage. Class name without layer suffix.

Returns:str
layer_id

Layer ID.

Returns:int layer id. if the layer is not assigned an id, -1.
left

Left coordinate. Writable.

Returns:int
mask

Returns mask associated with this layer.

Returns:Mask or None
name

Layer name. Writable.

Returns:str
offset

(left, top) tuple. Writable.

Returns:tuple
opacity

Opacity of this layer in [0, 255] range. Writable.

Returns:int
origination

Property for a list of live shapes or a line.

Some of the vector masks have associated live shape properties, that are Photoshop feature to handle primitive shapes such as a rectangle, an ellipse, or a line. Vector masks without live shape properties are plain path objects.

See psd_tools.api.shape.

Returns:List of Invalidated, Rectangle, RoundedRectangle, Ellipse, or Line.
parent

Parent of this layer.

resource_dict

Resource set.

right

Right coordinate.

Returns:int
size

(width, height) tuple.

Returns:tuple
stroke

Property for strokes.

tagged_blocks

Layer tagged blocks that is a dict-like container of settings.

See psd_tools.constants.Tag for available keys.

Returns:TaggedBlocks or None.

Example:

from psd_tools.constants import Tag
metadata = layer.tagged_blocks.get_data(Tag.METADATA_SETTING)
text

Text in the layer. Read-only.

Note

New-line character in Photoshop is ‘\r’.

top

Top coordinate. Writable.

Returns:int
topil(channel=None, **kwargs)

Get PIL Image of the layer.

Parameters:channel – Which channel to return; e.g., 0 for ‘R’ channel in RGB image. See ChannelID. When None, the method returns all the channels supported by PIL modes.
Returns:PIL.Image, or None if the layer has no pixels.

Example:

from psd_tools.constants import ChannelID

image = layer.topil()
red = layer.topil(ChannelID.CHANNEL_0)
alpha = layer.topil(ChannelID.TRANSPARENCY_MASK)

Note

Not all of the PSD image modes are supported in PIL.Image. For example, ‘CMYK’ mode cannot include alpha channel in PIL. In this case, topil drops alpha channel.

transform

Matrix (xx, xy, yx, yy, tx, ty) applies affine transformation.

vector_mask

Returns vector mask associated with this layer.

Returns:VectorMask or None
visible

Layer visibility. Doesn’t take group visibility in account. Writable.

Returns:bool
warp

Warp configuration.

width

Width of the layer.

Returns:int