psd_tools.api.adjustments

Adjustment and fill layers.

Example:

if layer.kind == 'brightnesscontrast':
    print(layer.brightness)

if layer.kind == 'gradient-fill':
    print(layer.gradient_kind)

Fill layers

Fill layers are similar to ShapeLayer except that the layer might not have an associated vector mask. The layer therefore expands the entire canvas of the PSD document.

Fill layers all inherit from FillLayer.

Example:

if isinstance(layer, psd_tools.layers.FillLayer):
    image = layer.compose()
class psd_tools.api.adjustments.SolidColorFill(*args)[source]

Solid color fill.

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(*args, **kwargs)

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

Returns:PIL.Image, or None if the layer has no pixel.
data

Color in Descriptor(RGB).

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_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, either of group, pixel, shape, type, smartobject, or psdimage.

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.

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
top

Top coordinate. Writable.

Returns:int
topil()

Get PIL Image of the layer.

Returns:PIL.Image, or None if the layer has no pixels.
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
class psd_tools.api.adjustments.PatternFill(*args)[source]

Pattern fill.

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(*args, **kwargs)

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

Returns:PIL.Image, or None if the layer has no pixel.
data

Pattern in Descriptor(PATTERN).

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_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, either of group, pixel, shape, type, smartobject, or psdimage.

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.

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
top

Top coordinate. Writable.

Returns:int
topil()

Get PIL Image of the layer.

Returns:PIL.Image, or None if the layer has no pixels.
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
class psd_tools.api.adjustments.GradientFill(*args)[source]

Gradient fill.

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(*args, **kwargs)

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

Returns:PIL.Image, or None if the layer has no pixel.
data

Gradient in Descriptor(GRADIENT).

effects

Layer effects.

Returns:Effects
gradient_kind

Kind of the gradient, one of the following:

  • linear
  • radial
  • angle
  • reflected
  • diamond
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_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, either of group, pixel, shape, type, smartobject, or psdimage.

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.

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
top

Top coordinate. Writable.

Returns:int
topil()

Get PIL Image of the layer.

Returns:PIL.Image, or None if the layer has no pixels.
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

Adjustment layers

Adjustment layers apply image filtering to the composed result. All adjustment layers inherit from AdjustmentLayer. Adjustment layers do not have pixels, and currently ignored in compose. Attempts to call topil on adjustment layers always return None.

Just as any other layer, adjustment layers might have an associated mask or vector mask. Adjustment can appear in other layers’ clipping layers.

Example:

if isinstance(layer, psd_tools.layers.AdjustmentLayer):
    print(layer.kind)
class psd_tools.api.adjustments.BrightnessContrast(*args)[source]

Brightness and contrast adjustment.

automatic
brightness
contrast
lab
mean
use_legacy
vrsn
class psd_tools.api.adjustments.Curves(*args)[source]

Curves adjustment.

data

Raw data.

Returns:Curves
extra
class psd_tools.api.adjustments.Exposure(*args)[source]

Exposure adjustment.

exposure

Exposure.

Returns:float
gamma

Gamma.

Returns:float
offset

Offset.

Returns:float
class psd_tools.api.adjustments.Levels(*args)[source]

Levels adjustment.

Levels contain a list of LevelRecord.

data

List of level records. The first record is the master.

Returns:Levels.
master

Master record.

class psd_tools.api.adjustments.Vibrance(*args)[source]

Vibrance adjustment.

saturation

Saturation.

Returns:int
vibrance

Vibrance.

Returns:int
class psd_tools.api.adjustments.HueSaturation(*args)[source]

Hue/Saturation adjustment.

HueSaturation contains a list of data.

colorization

Colorization.

Returns:tuple
data

List of Hue/Saturation records.

Returns:list
enable_colorization

Enable colorization.

Returns:int
master

Master record.

Returns:tuple
class psd_tools.api.adjustments.ColorBalance(*args)[source]

Color balance adjustment.

highlights

Highlights.

Returns:tuple
luminosity

Luminosity.

Returns:int
midtones

Mid-tones.

Returns:tuple
shadows

Shadows.

Returns:tuple
class psd_tools.api.adjustments.BlackAndWhite(*args)[source]

Black and white adjustment.

blue
cyan
green
magenta
preset_file_name
preset_kind
red
tint_color
use_tint
yellow
class psd_tools.api.adjustments.PhotoFilter(*args)[source]

Photo filter adjustment.

color_components
color_space
density
luminosity
xyz

xyz.

Returns:bool
class psd_tools.api.adjustments.ChannelMixer(*args)[source]

Channel mixer adjustment.

data
monochrome
class psd_tools.api.adjustments.ColorLookup(*args)[source]

Color lookup adjustment.

class psd_tools.api.adjustments.Posterize(*args)[source]

Posterize adjustment.

posterize

Posterize value.

Returns:int
class psd_tools.api.adjustments.Threshold(*args)[source]

Threshold adjustment.

threshold

Threshold value.

Returns:int
class psd_tools.api.adjustments.SelectiveColor(*args)[source]

Selective color adjustment.

data
method
class psd_tools.api.adjustments.GradientMap(*args)[source]

Gradient map adjustment.

color_model
color_stops
dithered
expansion
gradient_name
interpolation

Interpolation between 0.0 and 1.0.

length
max_color
min_color
mode
random_seed
reversed
roughness
show_transparency
transparency_stops
use_vector_color