psd_tools.psd.layer_and_mask
Layer and mask data structure.
LayerAndMaskInformation
- class psd_tools.psd.layer_and_mask.LayerAndMaskInformation(layer_info=None, global_layer_mask_info=None, tagged_blocks=None)[source]
Layer and mask information section.
- global_layer_mask_info
See
GlobalLayerMaskInfo
.
- tagged_blocks
See
TaggedBlocks
.
LayerInfo
- class psd_tools.psd.layer_and_mask.LayerInfo(layer_count: int = 0, layer_records=None, channel_image_data=None)[source]
High-level organization of the layer information.
- layer_count
Layer count. If it is a negative number, its absolute value is the number of layers and the first alpha channel contains the transparency data for the merged result.
- layer_records
Information about each layer. See
LayerRecords
.
- channel_image_data
Channel image data. See
ChannelImageData
.
GlobalLayerMaskInfo
- class psd_tools.psd.layer_and_mask.GlobalLayerMaskInfo(overlay_color=None, opacity: int = 0, kind=GlobalLayerMaskKind.PER_LAYER)[source]
Global mask information.
- overlay_color
Overlay color space (undocumented) and color components.
- opacity
Opacity. 0 = transparent, 100 = opaque.
- kind
Kind. 0 = Color selected–i.e. inverted; 1 = Color protected; 128 = use value stored per layer. This value is preferred. The others are for backward compatibility with beta versions.
LayerRecords
- class psd_tools.psd.layer_and_mask.LayerRecords(items=NOTHING)[source]
List of layer records. See
LayerRecord
.
LayerRecord
- class psd_tools.psd.layer_and_mask.LayerRecord(top: int = 0, left: int = 0, bottom: int = 0, right: int = 0, channel_info=NOTHING, signature: bytes = b'8BIM', blend_mode=BlendMode.NORMAL, opacity: int = 255, clipping=Clipping.BASE, flags=NOTHING, mask_data=None, blending_ranges=NOTHING, name: str = '', tagged_blocks=NOTHING)[source]
Layer record.
- top
Top position.
- left
Left position.
- bottom
Bottom position.
- right
Right position.
- channel_info
List of
ChannelInfo
.
- signature
Blend mode signature
b'8BIM'
.
- opacity
Opacity, 0 = transparent, 255 = opaque.
- flags
See
LayerFlags
.
- blending_ranges
See
LayerBlendingRanges
.
- name
Layer name.
- tagged_blocks
See
TaggedBlocks
.
- property channel_sizes
List of channel sizes: [(width, height)].
- property height
Height of the layer.
- property width
Width of the layer.
LayerFlags
- class psd_tools.psd.layer_and_mask.LayerFlags(transparency_protected: bool = False, visible: bool = True, obsolete: bool = False, photoshop_v5_later: bool = True, pixel_data_irrelevant: bool = False, undocumented_1: bool = False, undocumented_2: bool = False, undocumented_3: bool = False)[source]
Layer flags.
Note there are undocumented flags. Maybe photoshop version.
- transparency_protected
- visible
- pixel_data_irrelevant
LayerBlendingRanges
- class psd_tools.psd.layer_and_mask.LayerBlendingRanges(composite_ranges=NOTHING, channel_ranges=NOTHING)[source]
Layer blending ranges.
All ranges contain 2 black values followed by 2 white values.
- composite_ranges
List of composite gray blend source and destination ranges.
- channel_ranges
List of channel source and destination ranges.
MaskData
- class psd_tools.psd.layer_and_mask.MaskData(top: int = 0, left: int = 0, bottom: int = 0, right: int = 0, background_color: int = 0, flags=NOTHING, parameters=None, real_flags=None, real_background_color=None, real_top=None, real_left=None, real_bottom=None, real_right=None)[source]
Mask data.
Real user mask is a final composite mask of vector and pixel masks.
- top
Top position.
- left
Left position.
- bottom
Bottom position.
- right
Right position.
- background_color
Default color. 0 or 255.
- parameters
MaskParameters
or None.
- real_background_color
Real user mask background. 0 or 255.
- real_top
Top position of real user mask.
- real_left
Left position of real user mask.
- real_bottom
Bottom position of real user mask.
- real_right
Right position of real user mask.
- property height
Height of the mask.
- property real_height
Height of real user mask.
- property real_width
Width of real user mask.
- property width
Width of the mask.
MaskFlags
- class psd_tools.psd.layer_and_mask.MaskFlags(pos_relative_to_layer: bool = False, mask_disabled: bool = False, invert_mask: bool = False, user_mask_from_render: bool = False, parameters_applied: bool = False, undocumented_1: bool = False, undocumented_2: bool = False, undocumented_3: bool = False)[source]
Mask flags.
- pos_relative_to_layer
Position relative to layer.
- mask_disabled
Layer mask disabled.
- invert_mask
Invert layer mask when blending (Obsolete).
- user_mask_from_render
The user mask actually came from rendering other data.
- parameters_applied
The user and/or vector masks have parameters applied to them.
MaskParameters
ChannelInfo
- class psd_tools.psd.layer_and_mask.ChannelInfo(id=ChannelID.CHANNEL_0, length: int = 0)[source]
Channel information.
- id
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). See
ChannelID
.
- length
Length of the corresponding channel data.
ChannelImageData
- class psd_tools.psd.layer_and_mask.ChannelImageData(items=NOTHING)[source]
List of channel data list.
This size of this list corresponds to the size of
LayerRecords
. Each item corresponds to the channels of each layer.See
ChannelDataList
.
ChannelDataList
- class psd_tools.psd.layer_and_mask.ChannelDataList(items=NOTHING)[source]
List of channel image data, corresponding to each color or alpha.
See
ChannelData
.
ChannelData
- class psd_tools.psd.layer_and_mask.ChannelData(compression=Compression.RAW, data: bytes = b'')[source]
Channel data.
- compression
Compression type. See
Compression
.
- data
Data.
- get_data(width, height, depth, version=1)[source]
Get decompressed channel data.
- Parameters:
width – width.
height – height.
depth – bit depth of the pixel.
version – psd file version.
- Return type:
bytes
- set_data(data, width, height, depth, version=1)[source]
Set raw channel data and compress to store.
- Parameters:
data – raw data bytes to write.
compression – compression type, see
Compression
.width – width.
height – height.
depth – bit depth of the pixel.
version – psd file version.