pytoshop.layers¶
Sections related to image layers.
-
class
pytoshop.layers.ChannelImageData(image=None, fd=None, offset=None, size=None, shape=None, depth=None, version=None, compression=<Compression.raw: 0>)[source]¶ Bases:
objectA single plane of channel image data.
-
compression¶ Compression method. See
enums.Compression.
-
dtype¶
-
image¶
-
classmethod
read(fd, header, shape, size)[source]¶ Instantiate from a file-like object.
Parameters: - fd (file-like object) – Must be readable, seekable and open in binary mode.
- header (PsdFile object) – An object to get global file information from.
-
shape¶
-
-
class
pytoshop.layers.GlobalLayerMaskInfo(overlay_color_space=b'x00x00x00x00x00x00x00x00x00x00', opacity=100, kind=<LayerMaskKind.use_value_stored_per_layer: 128>)[source]¶ Bases:
objectGlobal layer mask info.
-
kind¶ Layer mask kind. See
enums.LayerMaskKind
-
opacity¶ Opacity. 0=transparent, 100=opaque
-
overlay_color_space¶ Undocumented
-
-
class
pytoshop.layers.LayerAndMaskInfo(layer_info=None, global_layer_mask_info=None, additional_layer_info=None)[source]¶ Bases:
objectLayer and mask information section.
-
additional_layer_info¶ List of additional layer info. See
TaggedBlock.
-
additional_layer_info_map¶ A mapping from tagged block codes to
tagged_block.TaggedBlockinstances.This is a convenience to more easily get associated tagged blocks.
-
global_layer_mask_info¶ Global layer mask info. See
GlobalLayerMaskInfo.
-
-
class
pytoshop.layers.LayerInfo(layer_records=None, use_alpha_channel=False)[source]¶ Bases:
objectA set of
LayerRecordinstances.-
layer_records¶ List of
LayerRecordinstances
-
classmethod
read(fd, header)[source]¶ Instantiate from a file-like object.
Parameters: - fd (file-like object) – Must be readable, seekable and open in binary mode.
- header (PsdFile object) – An object to get global file information from.
-
use_alpha_channel¶ Indicates that the first channel contains transparency data for the merged result.
-
-
class
pytoshop.layers.LayerMask(top=0, left=0, bottom=0, right=0, default_color=False, position_relative_to_layer=False, layer_mask_disabled=False, invert_layer_mask_when_blending=False, user_mask_from_rendering_other_data=False, user_mask_density=None, user_mask_feather=None, vector_mask_density=None, vector_mask_feather=None, real_flags=0, real_user_mask_background=False, real_top=0, real_left=0, real_bottom=0, real_right=0)[source]¶ Bases:
objectLayer mask / adjustment layer data.
-
bottom¶ Bottom of rectangle enclosing layer mask
-
default_color¶ Default color for mask
-
height¶ Height of the mask layer.
-
invert_layer_mask_when_blending¶ Invert layer mask when blending (obsolete)
-
layer_mask_disabled¶ Layer mask disabled
-
left¶ Left of rectangle enclosing layer mask
-
position_relative_to_layer¶ position relative to layer
-
classmethod
read(fd)[source]¶ Instantiate from a file-like object.
Parameters: - fd (file-like object) – Must be readable, seekable and open in binary mode.
- header (PsdFile object) – An object to get global file information from.
-
real_bottom¶
-
real_flags¶
-
real_height¶ Real height of the mask layer.
-
real_left¶
-
real_right¶
-
real_shape¶ Real shape of the mask layer
(height, width).
-
real_top¶
-
real_user_mask_background¶
-
real_width¶ Real width of the mask layer.
-
right¶ Right of rectangle enclosing layer mask
-
shape¶ Shape of the mask layer
(height, width).
-
top¶ Top of rectangle enclosing layer mask
-
user_mask_density¶ User mask density
-
user_mask_feather¶ User mask feather
-
user_mask_from_rendering_other_data¶ Indicates that the user mask actually came from rendering other data.
-
vector_mask_density¶ Vector mask density
-
vector_mask_feather¶ Vector mask feather
-
width¶ Width of the mask layer.
-
-
class
pytoshop.layers.LayerRecord(top=0, left=0, bottom=0, right=0, blend_mode=<BlendMode.normal: b'norm'>, opacity=255, clipping=False, transparency_protected=False, visible=True, pixel_data_irrelevant=False, name='', channels=None, blocks=None, color_mode=None)[source]¶ Bases:
objectLayer record.
There is one of these per logical layer in the file.
-
blend_mode¶ Blend mode. See
enums.BlendMode
-
blending_ranges¶
-
blocks¶ List of
tagged_block.TaggedBlockitems with additional information about this layer.
-
blocks_map¶ A mapping from tagged block codes to
tagged_block.TaggedBlockinstances.This is a convenience to more easily get associated tagged blocks.
-
bottom¶ Bottom of rectangle enclosing layer
-
channels¶ Dictionary from
enums.ChannelIdtoChannelImageData.For safety against different color modes, it is better to use
get_channelandset_channel.
-
clipping¶ Clipping. False=base, True=non-base
-
get_channel(color)[source]¶ Get a channel for a given color. Raises an error if the color space doesn’t have the given color.
Parameters: color (enums.ColorChannel) – Returns: channel Return type: ChannelImageData
-
height¶ Height of the layer.
-
left¶ Left of rectangle enclosing layer
-
mask¶
-
name¶ Name of layer
-
opacity¶ Opacity. 0=transparent, 255=opaque
-
pixel_data_irrelevant¶ Pixel data is irrelevant to appearance of document
-
classmethod
read(fd, header)[source]¶ Instantiate from a file-like object.
Parameters: - fd (file-like object) – Must be readable, seekable and open in binary mode.
- header (PsdFile object) – An object to get global file information from.
-
read_channel_data(fd, header)[source]¶ Read the
ChannelImageDatafor this layer.
-
right¶ Right of rectangle enclosing layer
-
set_channel(color, channel)[source]¶ Set a channel for a given color. Raises an error if the color space doesn’t have the given color.
Parameters: - color (enums.ColorChannel) –
- channel (ChannelImageData) –
-
shape¶ Shape of the layer
(height, width).
-
top¶ Top of rectangle enclosing layer
-
transparency_protected¶ Transparency protected
-
visible¶ Visible
-
width¶ Width of the layer.
-
write(fd, header)[source]¶ Write to a file-like object.
Parameters: - fd (file-like object) – Must be writable, seekable and open in binary mode.
- header (PsdFile object) – An object to get global file information from.
-
write_channel_data(fd, header)[source]¶ Write the
ChannelImageDatafor this layer.
-