psdtags

Read and write layered TIFF ImageSourceData and ImageResources tags.

Psdtags is a Python library to read and write the Adobe Photoshop(r) specific ImageResources (#34377) and ImageSourceData (#37724) TIFF tags, which contain image resource blocks, layer and mask information found in a typical layered TIFF file created by Photoshop.

The format is specified in the Adobe Photoshop TIFF Technical Notes (March 22, 2002) and Adobe Photoshop File Formats Specification (November 2019).

Adobe Photoshop is a registered trademark of Adobe Systems Inc.

Author:

Christoph Gohlke

License:

BSD-3-Clause

Version:

2026.11.1

DOI:

10.5281/zenodo.7879187

Quickstart

Install the psdtags package and all dependencies from the Python Package Index:

python -m pip install -U psdtags[all]

View the layer image and metadata stored in a layered TIFF file:

python -m psdtags file.tif

See Examples and Documentation for using the programming interface.

Source code, examples, and support are available on GitHub.

Requirements

This revision was tested with the following requirements and dependencies (other versions may work):

  • CPython 3.12.10, 3.13.17, 3.14.10, 3.15.2 64-bit

  • Numpy 2.5.4

  • Imagecodecs 2026.10.10 (required for compressing/decompressing image data)

  • Tifffile 2026.10.15 (required for reading/writing tags from/to TIFF files)

  • Matplotlib 3.11.2 (required for plotting)

Revisions

2026.11.1

  • Store multiple patterns in PsdPatterns, add PsdPattern class (breaking).

  • Return pseudo-members for undefined enum values (breaking).

  • Add PsdDescriptor and PsdDescriptorBlock opaque structures.

  • Add experimental PsdDescriptor and PsdDescriptorBlock parsing.

  • Skip opaque descriptors if unknown is False.

  • Fix unknown keys overwriting each other or being reversed.

  • Fix reading layer mask parameters and real user mask channel.

  • Fix reading LINKED_LAYER_EXTERNAL key.

  • Fix writing short PsdUnknown values.

  • Fix PsdMetadataSettings.write return value.

  • Replace PsdLayer.mask None with empty PsdLayerMask.

  • Drop support for Python 3.11 and numpy 2.1.

  • Support Python 3.15.

2026.1.29

  • Fix code review issues.

2026.1.8

  • Improve code quality.

  • …

Refer to the CHANGES file for older revisions.

Notes

The API is not stable yet and might change between revisions.

This library has been tested with a limited number of files only.

Additional layer information is not yet supported.

To enable experimental descriptor parsing, set the PSDTAGS_DESCRIPTOR_PARSING=1 environment variable.

Consider psd-tools and pytoshop for working with Adobe Photoshop PSD files.

Layered TIFF files can be read or written by Photoshop, Affinity Photo, and Krita.

See also Reading and writing a Photoshop TIFF.

Examples

Read the ImageSourceData tag value from a layered TIFF file and iterate over all the channels:

>>> from psdtags import TiffImageSourceData
>>> isd = TiffImageSourceData.fromtiff('layered.tif')
>>> for layer in isd.layers:
...     layer.name
...     for channel in layer.channels:
...         ch = channel.data  # a numpy array
...
'Background'
'Reflect1'
'Reflect2'
'image'
'Layer 1'
'ORight'
'I'
'IShadow'
'O'

Read the ImageResources tag value from the TIFF file, iterate over the blocks, and get the thumbnail image:

>>> from psdtags import TiffImageResources
>>> res = TiffImageResources.fromtiff('layered.tif')
>>> for block in res.blocks:
...     blockname = block.name
...
>>> res.thumbnail().shape
(90, 160, 3)

Write the image, ImageSourceData and ImageResources to a new layered TIFF file:

>>> from tifffile import imread, imwrite
>>> image = imread('layered.tif')
>>> imwrite(
...     '_layered.tif',
...     image,
...     byteorder=isd.byteorder,  # must match ImageSourceData
...     photometric='rgb',  # must match ImageSourceData
...     metadata=None,  # do not write any tifffile specific metadata
...     extratags=[isd.tifftag(maxworkers=4), res.tifftag()],
... )

Verify that the new layered TIFF file contains readable ImageSourceData:

>>> assert isd == TiffImageSourceData.fromtiff('_layered.tif')
>>> assert res == TiffImageResources.fromtiff('_layered.tif')

View the layer and mask information as well as the image resource blocks in a layered TIFF file from a command line:

python -m psdtags layered.tif

Refer to the layered_tiff.py example in the source distribution for creating a layered TIFF file from individual layer images.

License

Copyright (c) 2022-2026, Christoph Gohlke
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
   this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
   contributors may be used to endorse or promote products derived from
   this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

psdtags module

psdtags.__version__

Psdtags version string.

class psdtags.PsdBlendMode(*values)

Bases: BytesEnum

Blend modes.

UNKNOWN = b'?unk'
PASS_THROUGH = b'pass'
NORMAL = b'norm'
DISSOLVE = b'diss'
DARKEN = b'dark'
MULTIPLY = b'mul '
COLOR_BURN = b'idiv'
LINEAR_BURN = b'lbrn'
DARKER_COLOR = b'dkCl'
LIGHTEN = b'lite'
SCREEN = b'scrn'
COLOR_DODGE = b'div '
LINEAR_DODGE = b'lddg'
LIGHTER_COLOR = b'lgCl'
OVERLAY = b'over'
SOFT_LIGHT = b'sLit'
HARD_LIGHT = b'hLit'
VIVID_LIGHT = b'vLit'
LINEAR_LIGHT = b'lLit'
PIN_LIGHT = b'pLit'
HARD_MIX = b'hMix'
DIFFERENCE = b'diff'
EXCLUSION = b'smud'
SUBTRACT = b'fsub'
DIVIDE = b'fdiv'
HUE = b'hue '
SATURATION = b'sat '
COLOR = b'colr'
LUMINOSITY = b'lum '
tobytes(byteorder='>')

Return enum value as bytes.

Parameters:

byteorder (str)

Return type:

bytes

write(fh, byteorder='>', /)

Write enum value to open file.

Parameters:
  • fh (BinaryIO)

  • byteorder (str)

Return type:

int

value: bytes
class psdtags.PsdBoolean(key, value)

Bases: PsdKeyABC

Boolean.

Parameters:
key: PsdKey
value: bool
classmethod read(fh, psdformat, key, /, length)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write boolean to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, key, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.PsdBytesBlock(resourceid, value, name='')

Bases: PsdResourceBlockABC

Image resource blocks stored as opaque bytes.

Parameters:
resourceid: PsdResourceId
value: bytes
name: str = ''
classmethod read(fh, psdformat, resourceid, /, name, length)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance values to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, resourceid, /, name)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.PsdChannel(channelid, compression=PsdCompressionType.RAW, data=None, _data_length=0)

Bases: object

ChannelInfo and ChannelImageData.

Parameters:
channelid: PsdChannelId
compression: PsdCompressionType = 0
data: NDArray[Any] | None = None
classmethod read(fh, psdformat, /)

Return instance from open file.

Channel image data must be read separately using PsdChannel.read_image().

Parameters:
Return type:

Self

classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

Self

read_image(fh, psdformat, /, shape, dtype)

Read channel image data from open file.

Parameters:
  • fh (BinaryIO)

  • psdformat (PsdFormat)

  • shape (tuple[int, ...])

  • dtype (DTypeLike)

Return type:

None

tobytes(psdformat, /, compression=None)

Return channel info and image data records.

Parameters:
Return type:

tuple[bytes, bytes]

write(fh, psdformat, /, compression=None)

Write channel info record to file and return image data record.

Parameters:
Return type:

bytes

class psdtags.PsdChannelId(*values)

Bases: IntEnum

Channel types.

CHANNEL0 = 0
CHANNEL1 = 1
CHANNEL2 = 2
CHANNEL3 = 3
CHANNEL4 = 4
CHANNEL5 = 5
CHANNEL6 = 6
CHANNEL7 = 7
CHANNEL8 = 8
CHANNEL9 = 9
TRANSPARENCY_MASK = -1
USER_LAYER_MASK = -2
REAL_USER_LAYER_MASK = -3
class psdtags.PsdClippingType(*values)

Bases: IntEnum

Clipping types.

BASE = 0
NON_BASE = 1
class psdtags.PsdColorBlock(resourceid, colorspace, components=(0, 0, 0, 0), name='')

Bases: PsdResourceBlockABC

Color structure.

Parameters:
resourceid: PsdResourceId
colorspace: PsdColorSpaceType
components: tuple[int, int, int, int] = (0, 0, 0, 0)
name: str = ''
classmethod read(fh, psdformat, resourceid, /, name, length)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance values to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, resourceid, /, name)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.PsdColorSpaceType(*values)

Bases: IntEnum

Color space types.

UNKNOWN = -1
RGB = 0
HSB = 1
CMYK = 2
Pantone = 3
Focoltone = 4
Trumatch = 5
Toyo = 6
Lab = 7
Gray = 8
WideCMYK = 9
HKS = 10
DIC = 11
MonitorRGB = 13
Duotone = 14
Opacity = 15
Web = 16
GrayFloat = 17
RGBFloat = 18
OpacityFloat = 19
class psdtags.PsdColorType(*values)

Bases: IntEnum

Color IDs used by sheet color setting structure.

UNKNOWN = -1
NONE = 0
RED = 1
ORANGE = 2
YELLOW = 3
GREEN = 4
BLUE = 5
VIOLET = 6
GRAY = 7
class psdtags.PsdCompressionType(*values)

Bases: IntEnum

Image compression types.

UNKNOWN = -1
RAW = 0
RLE = 1
ZIP = 2
ZIP_PREDICTED = 3
class psdtags.PsdDescriptor(key, psdformat, value)

Bases: PsdUnknown

Descriptor structure stored as opaque bytes.

Parameters:
classmethod frombytes(data, psdformat, key, /)

Return instance from bytes.

Parameters:
Return type:

Self

classmethod read(fh, psdformat, key, /, length)

Return instance from open file.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return opaque binary value.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

write(fh, psdformat, /)

Write opaque binary value to open file.

Parameters:
Return type:

int

key: PsdKey
psdformat: PsdFormat
value: bytes
class psdtags.PsdDescriptorBlock(resourceid, value, name='')

Bases: PsdResourceBlockABC

Descriptor resource stored as opaque bytes.

Parameters:
resourceid: PsdResourceId
value: bytes
name: str = ''
classmethod read(fh, psdformat, resourceid, /, name, length)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance values to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, resourceid, /, name)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.PsdEmpty(key)

Bases: PsdKeyABC

Empty structure, no data associated with key.

Parameters:

key (PsdKey)

key: PsdKey
classmethod read(fh, psdformat, key, /, length)

Return instance from open file.

Parameters:
Return type:

Self

classmethod frombytes(data, psdformat, key, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return empty byte string.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

write(fh, psdformat, /)

Write nothing to open file.

Parameters:
Return type:

int

class psdtags.PsdExposure(exposure, offset, gamma)

Bases: PsdKeyABC

Exposure.

Parameters:
  • exposure (float)

  • offset (float)

  • gamma (float)

exposure: float
offset: float
gamma: float
key: PsdKey = b'expA'
classmethod read(fh, psdformat, key, /, length)

Return exposure from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write exposure to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, key, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.PsdFilterMask(colorspace, components=(0, 0, 0, 0), opacity=0)

Bases: PsdKeyABC

Filter Mask (Photoshop CS3).

Parameters:
  • colorspace (PsdColorSpaceType)

  • components (tuple[int, int, int, int])

  • opacity (int)

colorspace: PsdColorSpaceType
components: tuple[int, int, int, int] = (0, 0, 0, 0)
opacity: int = 0
key: PsdKey = b'FMsk'
classmethod read(fh, psdformat, key, /, length)

Return instance from open file.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return filter mask record.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

write(fh, psdformat, /)

Write filter mask record to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, key, /)

Return instance from bytes.

Parameters:
Return type:

Self

class psdtags.PsdFormat(*values)

Bases: bytes, Enum

PSD format.

BE32BIT = b'8BIM'
LE32BIT = b'MIB8'
BE64BIT = b'8B64'
LE64BIT = b'46B8'
property byteorder: Literal['>', '<']

Byte-order of PSD format.

property sizeformat: str

Struct format string for size values.

property utf16: str

UTF-16 encoding.

property isb64: bool

PSD format is 64-bit.

read(fh, fmt)

Return unpacked values.

Parameters:
  • fh (BinaryIO)

  • fmt (str)

Return type:

Any

write(fh, fmt, *values)

Write values to open file.

Parameters:
  • fh (BinaryIO)

  • fmt (str)

  • values (Any)

Return type:

int

pack(fmt, *values)

Return packed values.

Parameters:
  • fmt (str)

  • values (Any)

Return type:

bytes

read_size(fh, key=None)

Return integer whose size depends on signature or key from file.

Parameters:
  • fh (BinaryIO)

  • key (PsdKey | None)

Return type:

int

write_size(fh, value, key=None)

Write integer whose size depends on signature or key to file.

Parameters:
  • fh (BinaryIO)

  • value (int)

  • key (PsdKey | None)

Return type:

int

pack_size(value, key=None)

Pack integer whose size depends on signature or key.

Parameters:
  • value (int)

  • key (PsdKey | None)

Return type:

bytes

read_signature(fh, /)

Return four-byte signature or key from file in big-endian order.

Parameters:

fh (BinaryIO)

Return type:

bytes

write_signature(fh, signature, /)

Write signature to file.

Parameters:
  • fh (BinaryIO)

  • signature (bytes)

Return type:

int

write_key(fh, key, /)

Write signature to file.

Parameters:
Return type:

int

class psdtags.PsdImageMode(*values)

Bases: IntEnum

Image modes.

UNKNOWN = -1
Bitmap = 0
Grayscale = 1
Indexed = 2
RGB = 3
CMYK = 4
Multichannel = 7
Duotone = 8
Lab = 9
class psdtags.PsdInteger(key, value)

Bases: PsdKeyABC

4 Byte Integer.

Parameters:
key: PsdKey
value: int
classmethod read(fh, psdformat, key, /, length)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write integer to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, key, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.PsdKey(*values)

Bases: BytesEnum

Keys of tagged structures.

UNKNOWN = b'?unk'
ALPHA = b'Alph'
ANIMATION_EFFECTS = b'anFX'
ANNOTATIONS = b'Anno'
ARTBOARD_DATA = b'artb'
ARTBOARD_DATA_2 = b'artd'
ARTBOARD_DATA_3 = b'abdd'
BLACK_AND_WHITE = b'blwh'
BLEND_CLIPPING_ELEMENTS = b'clbl'
BLEND_INTERIOR_ELEMENTS = b'infx'
BRIGHTNESS_AND_CONTRAST = b'brit'
CAI = b'CAI '
CHANNEL_BLENDING_RESTRICTIONS_SETTING = b'brst'
CHANNEL_MIXER = b'mixr'
COLOR_BALANCE = b'blnc'
COLOR_LOOKUP = b'clrL'
COMPOSITOR_USED = b'cinf'
CONTENT_GENERATOR_EXTRA_DATA = b'CgEd'
CURVES = b'curv'
EFFECTS_LAYER = b'lrFX'
EXPOSURE = b'expA'
FILL_OPACITY = b'iOpa'
FILTER_EFFECTS = b'FXid'
FILTER_EFFECTS_2 = b'FEid'
FILTER_MASK = b'FMsk'
FOREIGN_EFFECT_ID = b'ffxi'
FRAMED_GROUP = b'frgb'
GENI = b'GenI'
GRADIENT_FILL_SETTING = b'GdFl'
GRADIENT_MAP = b'grdm'
HUE_SATURATION = b'hue2'
HUE_SATURATION_PS4 = b'hue '
INVERT = b'nvrt'
KNOCKOUT_SETTING = b'knko'
LAYER = b'Layr'
LAYER_16 = b'Lr16'
LAYER_32 = b'Lr32'
LAYER_ID = b'lyid'
LAYER_MASK_AS_GLOBAL_MASK = b'lmgm'
LAYER_NAME_SOURCE_SETTING = b'lnsr'
LAYER_VERSION = b'lyvr'
LEVELS = b'levl'
LINKED_LAYER = b'lnkD'
LINKED_LAYER_2 = b'lnk2'
LINKED_LAYER_3 = b'lnk3'
LINKED_LAYER_EXTERNAL = b'lnkE'
METADATA_SETTING = b'shmd'
NESTED_SECTION_DIVIDER_SETTING = b'lsdk'
OBJECT_BASED_EFFECTS_LAYER_INFO = b'lfx2'
OCIO = b'OCIO'
PATT = b'patt'
PATTERNS = b'Patt'
PATTERNS_2 = b'Pat2'
PATTERNS_3 = b'Pat3'
PATTERN_DATA = b'shpa'
PATTERN_FILL_SETTING = b'PtFl'
PHOTO_FILTER = b'phfl'
PIXEL_SOURCE_DATA = b'PxSc'
PIXEL_SOURCE_DATA_CC15 = b'PxSD'
PLACED_LAYER = b'plLd'
PLACED_LAYER_CS3 = b'PlLd'
POSTERIZE = b'post'
PROTECTED_SETTING = b'lspf'
REFERENCE_POINT = b'fxrp'
SAVING_MERGED_TRANSPARENCY = b'Mtrn'
SAVING_MERGED_TRANSPARENCY2 = b'MTrn'
SAVING_MERGED_TRANSPARENCY_16 = b'Mt16'
SAVING_MERGED_TRANSPARENCY_32 = b'Mt32'
SECTION_DIVIDER_SETTING = b'lsct'
SELECTIVE_COLOR = b'selc'
SHEET_COLOR_SETTING = b'lclr'
SMART_OBJECT_LAYER_DATA = b'SoLd'
SMART_OBJECT_LAYER_DATA_CC15 = b'SoLE'
SOLID_COLOR_SHEET_SETTING = b'SoCo'
TEXT_ENGINE_DATA = b'Txt2'
THRESHOLD = b'thrs'
TRANSPARENCY_SHAPES_LAYER = b'tsly'
TYPE_TOOL_INFO = b'tySh'
TYPE_TOOL_OBJECT_SETTING = b'TySh'
UNICODE_LAYER_NAME = b'luni'
UNICODE_PATH_NAME = b'pths'
USER_MASK = b'LMsk'
USING_ALIGNED_RENDERING = b'sn2P'
VECTOR_MASK_AS_GLOBAL_MASK = b'vmgm'
VECTOR_MASK_SETTING = b'vmsk'
VECTOR_MASK_SETTING_CS6 = b'vsms'
VECTOR_ORIGINATION_DATA = b'vogk'
VECTOR_STROKE_DATA = b'vstk'
VECTOR_STROKE_CONTENT_DATA = b'vscg'
VIBRANCE = b'vibA'
tobytes(byteorder='>')

Return enum value as bytes.

Parameters:

byteorder (str)

Return type:

bytes

write(fh, byteorder='>', /)

Write enum value to open file.

Parameters:
  • fh (BinaryIO)

  • byteorder (str)

Return type:

int

value: bytes
class psdtags.PsdKeyABC

Bases: object

Abstract base class for structures with key.

key: PsdKey
abstractmethod classmethod read(fh, psdformat, key, /, length)

Return instance from open file.

Parameters:
Return type:

Self

classmethod frombytes(data, psdformat, key, /)

Return instance from bytes.

Parameters:
Return type:

Self

abstractmethod write(fh, psdformat, /)

Write instance values to open file.

Parameters:
Return type:

int

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.PsdLayer(name, channels, rectangle, mask=<factory>, opacity=255, blendmode=PsdBlendMode.NORMAL, blending_ranges=(), clipping=PsdClippingType.BASE, flags=<PsdLayerFlag.BASE: 0>, info=<factory>)

Bases: object

PSD layer record.

Parameters:
name: str
channels: list[PsdChannel]
rectangle: PsdRectangle
mask: PsdLayerMask
opacity: int = 255
blendmode: PsdBlendMode = b'norm'
blending_ranges: tuple[int, ...] = ()
clipping: PsdClippingType = 0
flags: PsdLayerFlag = 0
info: list[Any]
classmethod read(fh, psdformat, /, *, unknown=True)

Return instance from open file.

Channel image data must be read separately.

Parameters:
  • fh (BinaryIO)

  • psdformat (PsdFormat)

  • unknown (bool)

Return type:

Self

classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

Self

write(fh, psdformat, /, *, compression=None, unknown=True, maxworkers=1)

Write layer record to open file and return channel data records.

Parameters:
Return type:

bytes

tobytes(psdformat, /, *, compression=None, unknown=True, maxworkers=1)

Return layer and channel data records.

Parameters:
Return type:

tuple[bytes, bytes]

asarray(*, channelid=None, planar=False)

Return channel image data.

Parameters:
Return type:

NDArray[Any]

property shape: tuple[int, int]

Height and width of layer image.

property offset: tuple[int, int]

Top-left position of layer image.

property title: str

Name of layer.

property has_unknowns: bool

Layer has unknown structures in info.

class psdtags.PsdLayerFlag(*values)

Bases: IntFlag

Layer record flags.

BASE = 0
TRANSPARENCY_PROTECTED = 1
VISIBLE = 2
OBSOLETE = 4
PHOTOSHOP5 = 8
IRRELEVANT = 16
class psdtags.PsdLayerMask(default_color=0, rectangle=None, flags=<PsdLayerMaskFlag.BASE: 0>, user_mask_density=None, user_mask_feather=None, vector_mask_density=None, vector_mask_feather=None, real_flags=None, real_background=None, real_rectangle=None)

Bases: object

Layer mask / adjustment layer data.

Parameters:
  • default_color (int)

  • rectangle (PsdRectangle | None)

  • flags (PsdLayerMaskFlag)

  • user_mask_density (int | None)

  • user_mask_feather (float | None)

  • vector_mask_density (int | None)

  • vector_mask_feather (float | None)

  • real_flags (PsdLayerMaskFlag | None)

  • real_background (int | None)

  • real_rectangle (PsdRectangle | None)

default_color: int = 0
rectangle: PsdRectangle | None = None
flags: PsdLayerMaskFlag = 0
user_mask_density: int | None = None
user_mask_feather: float | None = None
vector_mask_density: int | None = None
vector_mask_feather: float | None = None
real_flags: PsdLayerMaskFlag | None = None
real_background: int | None = None
real_rectangle: PsdRectangle | None = None
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return layer mask structure.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

write(fh, psdformat, /)

Write layer mask structure to open file.

Parameters:
Return type:

int

property param_flags: PsdLayerMaskParameterFlag

Layer mask parameter flags.

property shape: tuple[int, int]

Height and width of layer mask.

property offset: tuple[int, int]

Top-left position of layer mask.

class psdtags.PsdLayerMaskFlag(*values)

Bases: IntFlag

Layer mask flags.

BASE = 0
RELATIVE = 1
DISABLED = 2
INVERT = 4
RENDERED = 8
APPLIED = 16
class psdtags.PsdLayerMaskParameterFlag(*values)

Bases: IntFlag

Layer mask parameters.

BASE = 0
USER_DENSITY = 1
USER_FEATHER = 2
VECTOR_DENSITY = 4
VECTOR_FEATHER = 8
class psdtags.PsdLayers(key, layers=<factory>, has_transparency=False)

Bases: PsdKeyABC

Sequence of PsdLayer.

Parameters:
key: PsdKey
layers: list[PsdLayer]
has_transparency: bool = False
TYPES: ClassVar[dict[PsdKey, str]]
classmethod read(fh, psdformat, key, /, length, *, unknown=True)

Return instance from open file.

Parameters:
  • fh (BinaryIO)

  • psdformat (PsdFormat)

  • key (PsdKey)

  • length (int)

  • unknown (bool)

Return type:

Self

classmethod frombytes(data, psdformat, key, /, *, unknown=True)

Return instance from bytes.

Parameters:
Return type:

Self

write(fh, psdformat, /, *, compression=None, unknown=True, maxworkers=1)

Write layer records and channel info data to open file.

Parameters:
Return type:

int

tobytes(psdformat, /, *, compression=None, unknown=True, maxworkers=1)

Return layer records and channel info data as bytes.

Parameters:
Return type:

bytes

property dtype: numpy.dtype[Any]

Data type of layer images.

property shape: tuple[int, int]

Height and width of layer images.

class psdtags.PsdMetadataSetting(signature, key, data=b'', copyonsheet=False)

Bases: object

Metadata setting item.

Parameters:
  • signature (PsdFormat)

  • key (bytes)

  • data (bytes)

  • copyonsheet (bool)

signature: PsdFormat
key: bytes
data: bytes = b''
copyonsheet: bool = False
classmethod read(fh, psdformat)

Return metadata setting from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write metadata setting to open file.

Parameters:
Return type:

int

class psdtags.PsdMetadataSettings(items=<factory>)

Bases: PsdKeyABC

Metadata setting (Photoshop 6.0).

Parameters:

items (list[PsdMetadataSetting])

items: list[PsdMetadataSetting]
key: PsdKey = b'shmd'
classmethod read(fh, psdformat, key, /, length)

Return metadata settings from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write metadata settings to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, key, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.PsdPascalString(value)

Bases: object

Pascal string.

Parameters:

value (str)

value: str
classmethod read(fh, pad=1)

Return instance from open file.

Parameters:
  • fh (BinaryIO)

  • pad (int)

Return type:

Self

write(fh, pad=1)

Write Pascal string to open file.

Parameters:
  • fh (BinaryIO)

  • pad (int)

Return type:

int

class psdtags.PsdPascalStringBlock(resourceid, value, name='')

Bases: PsdResourceBlockABC

Pascal string.

Parameters:
resourceid: PsdResourceId
value: str
name: str = ''
classmethod read(fh, psdformat, resourceid, /, name, length)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write Pascal string to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, resourceid, /, name)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.PsdPascalStringsBlock(resourceid, values, name='')

Bases: PsdResourceBlockABC

Series of Pascal strings.

Parameters:
resourceid: PsdResourceId
values: list[str]
name: str = ''
classmethod read(fh, psdformat, resourceid, /, name, length)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write sequence of Pascal strings to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, resourceid, /, name)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.PsdPattern(imagemode, name, guid, data, colortable=None, point=<factory>)

Bases: object

Pattern item of PsdPatterns.

Parameters:
imagemode: PsdImageMode
name: str
guid: str
data: PsdVirtualMemoryArrayList
colortable: NDArray[numpy.uint8] | None = None
point: PsdPoint
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write pattern to open file.

Parameters:
Return type:

int

asarray(*, planar=False)

Return channel image data.

Parameters:

planar (bool)

Return type:

NDArray[Any]

class psdtags.PsdPatterns(key, patterns=<factory>)

Bases: PsdKeyABC

Patterns (Photoshop 6.0 and CS 8.0).

Parameters:
key: PsdKey
patterns: list[PsdPattern]
classmethod read(fh, psdformat, key, /, length)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write patterns to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, key, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.PsdPoint(y, x)

Bases: NamedTuple

Point.

Parameters:
  • y (int)

  • x (int)

class psdtags.PsdRectangle(top, left, bottom, right)

Bases: NamedTuple

Rectangle.

Parameters:
  • top (int)

  • left (int)

  • bottom (int)

  • right (int)

property shape: tuple[int, int]

Height and width of rectangle.

property offset: tuple[int, int]

Top-left position of rectangle.

class psdtags.PsdReferencePoint(x, y)

Bases: PsdKeyABC

Reference point.

Parameters:
  • x (float)

  • y (float)

x: float
y: float
key: PsdKey = b'fxrp'
classmethod read(fh, psdformat, key, /, length)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write reference point to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, key, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.PsdResourceBlockABC

Bases: object

Abstract base class for image resource block data.

resourceid: PsdResourceId
name: str
abstractmethod classmethod read(fh, psdformat, resourceid, /, name, length)

Return instance from open file.

Parameters:
Return type:

Self

classmethod frombytes(data, psdformat, resourceid, /, name)

Return instance from bytes.

Parameters:
Return type:

Self

abstractmethod write(fh, psdformat, /)

Write instance values to open file.

Parameters:
Return type:

int

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.PsdResourceId(*values)

Bases: IntEnum

Image resource IDs.

UNKNOWN = -1
OBSOLETE_1 = 1000
MAC_PRINT_MANAGER_INFO = 1001
MAC_PAGE_FORMAT_INFO = 1002
OBSOLETE_2 = 1003
RESOLUTION_INFO = 1005
ALPHA_NAMES_PASCAL = 1006
DISPLAY_INFO_OBSOLETE = 1007
CAPTION_PASCAL = 1008
BORDER_INFO = 1009
BACKGROUND_COLOR = 1010
PRINT_FLAGS = 1011
GRAYSCALE_HALFTONING_INFO = 1012
COLOR_HALFTONING_INFO = 1013
DUOTONE_HALFTONING_INFO = 1014
GRAYSCALE_TRANSFER_FUNCTION = 1015
COLOR_TRANSFER_FUNCTION = 1016
DUOTONE_TRANSFER_FUNCTION = 1017
DUOTONE_IMAGE_INFO = 1018
EFFECTIVE_BW = 1019
OBSOLETE_3 = 1020
EPS_OPTIONS = 1021
QUICK_MASK_INFO = 1022
OBSOLETE_4 = 1023
LAYER_STATE_INFO = 1024
WORKING_PATH = 1025
LAYER_GROUP_INFO = 1026
OBSOLETE_5 = 1027
IPTC_NAA = 1028
IMAGE_MODE_RAW = 1029
JPEG_QUALITY = 1030
GRID_AND_GUIDES_INFO = 1032
THUMBNAIL_RESOURCE_PS4 = 1033
COPYRIGHT_FLAG = 1034
URL = 1035
THUMBNAIL_RESOURCE = 1036
GLOBAL_ANGLE = 1037
COLOR_SAMPLERS_RESOURCE_OBSOLETE = 1038
ICC_PROFILE = 1039
WATERMARK = 1040
ICC_UNTAGGED_PROFILE = 1041
EFFECTS_VISIBLE = 1042
SPOT_HALFTONE = 1043
IDS_SEED_NUMBER = 1044
ALPHA_NAMES_UNICODE = 1045
INDEXED_COLOR_TABLE_COUNT = 1046
TRANSPARENCY_INDEX = 1047
GLOBAL_ALTITUDE = 1049
SLICES = 1050
WORKFLOW_URL = 1051
JUMP_TO_XPEP = 1052
ALPHA_IDENTIFIERS = 1053
URL_LIST = 1054
VERSION_INFO = 1057
EXIF_DATA_1 = 1058
EXIF_DATA_3 = 1059
XMP_METADATA = 1060
CAPTION_DIGEST = 1061
PRINT_SCALE = 1062
PIXEL_ASPECT_RATIO = 1064
LAYER_COMPS = 1065
ALTERNATE_DUOTONE_COLORS = 1066
ALTERNATE_SPOT_COLORS = 1067
LAYER_SELECTION_IDS = 1069
HDR_TONING_INFO = 1070
PRINT_INFO_CS2 = 1071
LAYER_GROUPS_ENABLED_ID = 1072
COLOR_SAMPLERS_RESOURCE = 1073
MEASUREMENT_SCALE = 1074
TIMELINE_INFO = 1075
SHEET_DISCLOSURE = 1076
DISPLAY_INFO = 1077
ONION_SKINS = 1078
COUNT_INFO = 1080
PRINT_INFO_CS5 = 1082
PRINT_STYLE = 1083
MAC_NSPRINTINFO = 1084
WINDOWS_DEVMODE = 1085
AUTO_SAVE_FILE_PATH = 1086
AUTO_SAVE_FORMAT = 1087
PATH_SELECTION_STATE = 1088
PATH_INFO = 2000
CLIPPING_PATH_NAME = 2999
ORIGIN_PATH_INFO = 3000
PLUGIN_RESOURCE = 4000
IMAGE_READY_VARIABLES = 7000
IMAGE_READY_DATA_SETS = 7001
IMAGE_READY_DEFAULT_SELECTED_STATE = 7002
IMAGE_READY_7_ROLLOVER_EXPANDED_STATE = 7003
IMAGE_READY_ROLLOVER_EXPANDED_STATE = 7004
IMAGE_READY_SAVE_LAYER_SETTINGS = 7005
IMAGE_READY_VERSION = 7006
LIGHTROOM_WORKFLOW = 8000
PRINT_FLAGS_INFO = 10000
class psdtags.PsdSectionDividerSetting(kind, blendmode=None, subtype=None)

Bases: PsdKeyABC

Section divider setting (Photoshop 6.0).

Parameters:
kind: PsdSectionDividerType
blendmode: PsdBlendMode | None = None
subtype: int | None = None
key: PsdKey = b'lsct'
classmethod read(fh, psdformat, key, /, length)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write section divider setting to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, key, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.PsdSectionDividerType(*values)

Bases: IntEnum

Section divider setting types.

UNKNOWN = -1
OTHER = 0
OPEN_FOLDER = 1
CLOSED_FOLDER = 2
BOUNDING_SECTION_DIVIDER = 3
class psdtags.PsdSheetColorSetting(color)

Bases: PsdKeyABC

Sheet color setting (Photoshop 6.0).

Parameters:

color (PsdColorType)

color: PsdColorType
key: PsdKey = b'lclr'
classmethod read(fh, psdformat, key, /, length)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write color setting to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, key, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.PsdString(key, value)

Bases: PsdKeyABC

Unicode string.

Parameters:
key: PsdKey
value: str
classmethod read(fh, psdformat, key, /, length)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write unicode string to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, key, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.PsdStringBlock(resourceid, value, name='')

Bases: PsdResourceBlockABC

Unicode string.

Parameters:
resourceid: PsdResourceId
value: str
name: str = ''
classmethod read(fh, psdformat, resourceid, /, name, length)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write Pascal string to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, resourceid, /, name)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.PsdStringsBlock(resourceid, values, name='')

Bases: PsdResourceBlockABC

Series of Unicode strings.

Parameters:
resourceid: PsdResourceId
values: list[str]
name: str = ''
classmethod read(fh, psdformat, resourceid, /, name, length)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write sequence of Unicode strings to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, resourceid, /, name)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.PsdTextEngineData(data)

Bases: PsdKeyABC

Text engine data (Photoshop CS3).

Parameters:

data (bytes)

data: bytes
key: PsdKey = b'Txt2'
classmethod read(fh, psdformat, key, /, length)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write unicode string to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, key, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.PsdThumbnailBlock(resourceid, format, width, height, rawdata, name='')

Bases: PsdResourceBlockABC

Thumbnail resource format.

Parameters:
resourceid: PsdResourceId
format: PsdThumbnailFormat
width: int
height: int
rawdata: bytes
name: str = ''
classmethod read(fh, psdformat, resourceid, /, name, length)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write Thumbnail resource format to open file.

Parameters:
Return type:

int

property is_bgr: bool

Thumbnail image is BGR.

property data: NDArray[Any]

Thumbnail image array.

property title: str

Short representation of instance.

classmethod frombytes(data, psdformat, resourceid, /, name)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.PsdThumbnailFormat(*values)

Bases: IntEnum

PsdThumbnailBlock format types.

UNKNOWN = -1
RAW_RGB = 0
JPEG_RGB = 1
class psdtags.PsdUnicodeString(value)

Bases: object

Unicode string.

Parameters:

value (str)

value: str
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /, *, terminate=True)

Write unicode string to open file.

Parameters:
  • fh (BinaryIO)

  • psdformat (PsdFormat)

  • terminate (bool)

Return type:

int

class psdtags.PsdUnknown(key, psdformat, value)

Bases: PsdKeyABC

Unknown keys stored as opaque bytes.

Parameters:
key: PsdKey
psdformat: PsdFormat
value: bytes
classmethod frombytes(data, psdformat, key, /)

Return instance from bytes.

Parameters:
Return type:

Self

classmethod read(fh, psdformat, key, /, length)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write opaque binary value to open file.

Parameters:
Return type:

int

tobytes(psdformat, /)

Return opaque binary value.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.PsdUserMask(colorspace=PsdColorSpaceType.UNKNOWN, components=(0, 0, 0, 0), opacity=0, flag=128)

Bases: PsdKeyABC

User mask. Same as global layer mask info table.

Parameters:
  • colorspace (PsdColorSpaceType)

  • components (tuple[int, int, int, int])

  • opacity (int)

  • flag (int)

colorspace: PsdColorSpaceType = -1
components: tuple[int, int, int, int] = (0, 0, 0, 0)
opacity: int = 0
flag: int = 128
key: PsdKey = b'LMsk'
classmethod read(fh, psdformat, key, /, length)

Return instance from open file.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return user mask record.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

write(fh, psdformat, /)

Write user mask record to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, key, /)

Return instance from bytes.

Parameters:
Return type:

Self

class psdtags.PsdVersionBlock(resourceid, version, file_version, writer_name, reader_name, has_real_merged_data, name='')

Bases: PsdResourceBlockABC

Image resource blocks stored as opaque bytes.

Parameters:
  • resourceid (PsdResourceId)

  • version (int)

  • file_version (int)

  • writer_name (str)

  • reader_name (str)

  • has_real_merged_data (bool)

  • name (str)

resourceid: PsdResourceId
version: int
file_version: int
writer_name: str
reader_name: str
has_real_merged_data: bool
name: str = ''
classmethod read(fh, psdformat, resourceid, /, name, length)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance values to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, resourceid, /, name)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.PsdVirtualMemoryArray(iswritten=False, depth=None, rectangle=None, pixeldepth=None, compression=PsdCompressionType.RAW, data=None)

Bases: object

Virtual memory array.

Parameters:
  • iswritten (bool)

  • depth (int | None)

  • rectangle (PsdRectangle | None)

  • pixeldepth (int | None)

  • compression (PsdCompressionType)

  • data (NDArray[Any] | None)

iswritten: bool = False
depth: int | None = None
rectangle: PsdRectangle | None = None
pixeldepth: int | None = None
compression: PsdCompressionType = 0
data: NDArray[Any] | None = None
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write virtual memory array to open file.

Parameters:
Return type:

int

property dtype: numpy.dtype[Any]

Data type of virtual memory array.

property shape: tuple[int, int]

Height and width of virtual memory array.

property offset: tuple[int, int]

Top-left position of virtual memory array.

class psdtags.PsdVirtualMemoryArrayList(rectangle, channels=<factory>)

Bases: object

Virtual memory array list.

Parameters:
rectangle: PsdRectangle
channels: list[PsdVirtualMemoryArray]
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write virtual memory array list to open file.

Parameters:
Return type:

int

class psdtags.PsdWord(key, value)

Bases: PsdKeyABC

Four bytes.

Parameters:
key: PsdKey
value: bytes
classmethod read(fh, psdformat, key, /, length)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write four bytes value to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, key, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.TiffImageResources(psdformat, blocks, name=None)

Bases: object

TIFF ImageResources tag #34377.

Parameters:
psdformat: PsdFormat
blocks: list[PsdResourceBlockABC]
name: str | None = None
classmethod read(fh, length, name=None)

Return instance from open file.

Parameters:
  • fh (BinaryIO)

  • length (int)

  • name (str | None)

Return type:

Self

classmethod frombytes(data, name=None)

Return instance from ImageResources tag value.

Parameters:
  • data (bytes)

  • name (str | None)

Return type:

Self

classmethod fromtiff(filename, /, pageindex=0)

Return instance from ImageResources tag in TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str)

  • pageindex (int)

Return type:

Self

write(fh)

Write ImageResources tag value to open file.

Parameters:

fh (BinaryIO)

Return type:

int

tobytes()

Return ImageResources tag value as bytes.

Return type:

bytes

tifftag()

Return tifffile.TiffWriter.write extratags item.

Return type:

tuple[int, int, int, bytes, bool]

thumbnail()

Return thumbnail image if any, else None.

Return type:

NDArray[Any] | None

property blocks_dict: dict[int, PsdResourceBlockABC]

Dictionary of PsdResourceBlock by value.

class psdtags.TiffImageSourceData(psdformat, layers, usermask, info=<factory>, name=None)

Bases: object

TIFF ImageSourceData tag #37724.

Parameters:
psdformat: PsdFormat
layers: PsdLayers
usermask: PsdUserMask
info: list[PsdKeyABC]
name: str | None = None
SIGNATURE = b'Adobe Photoshop Document Data Block\x00'
classmethod read(fh, /, name=None, *, unknown=True)

Return instance from open file.

Parameters:
  • fh (BinaryIO)

  • name (str | None)

  • unknown (bool)

Return type:

Self

classmethod frombytes(data, /, *, name=None, unknown=True)

Return instance from bytes.

Parameters:
  • data (bytes)

  • name (str | None)

  • unknown (bool)

Return type:

Self

classmethod fromtiff(filename, /, *, pageindex=0, unknown=True)

Return instance from TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str)

  • pageindex (int)

  • unknown (bool)

Return type:

Self

write(fh, /, psdformat=None, *, compression=None, unknown=True, maxworkers=1)

Write ImageResourceData tag value to open file.

Parameters:
Return type:

int

tobytes(psdformat=None, *, compression=None, unknown=True, maxworkers=1)

Return ImageResourceData tag value as bytes.

Parameters:
Return type:

bytes

tifftag(psdformat=None, compression=None, *, unknown=True, maxworkers=1)

Return tifffile.TiffWriter.write extratags item.

Parameters:
Return type:

tuple[int, int, int, bytes, bool]

property byteorder: Literal['>', '<']

Byte-order of PSD structures.

property has_unknowns: bool

ImageSourceData has unknown structures in info or layers.

psdtags.compress(data, compression, rlecountfmt)

Return compressed big-endian numpy array.

Parameters:
Return type:

bytes

psdtags.decompress(data, compression, shape, dtype, rlecountfmt)

Return decompressed numpy array.

Parameters:
  • data (bytes | bytearray | memoryview)

  • compression (PsdCompressionType)

  • shape (tuple[int, ...])

  • dtype (DTypeLike)

  • rlecountfmt (str)

Return type:

NDArray[Any]

psdtags.overlay(*layers, shape=None, vmax=None)

Return overlay of image layers with unassociated alpha channels.

Consider using image-blender for an implementation of Adobe Photoshop’s blend modes.

Parameters:
  • layers (tuple[NDArray[Any], tuple[int, int] | None]) – RGBA image array and offset of layer in canvas. Layers must not exceed the canvas boundaries and must all have the same data types. Alpha channels are unassociated.

  • shape (tuple[int, ...] | None) – Canvas height and width. By default, this is determined from the first layer.

  • vmax (float | None) – Value used to normalize layer values. By default, this is determined from data type of the first layer.

Returns:

Overlay of image layers.

Return type:

NDArray[Any]

psdtags.read_psdblocks(fh, /, length)

Return list of image resource block values from open file.

Parameters:
  • fh (BinaryIO)

  • length (int)

Return type:

list[PsdResourceBlockABC]

psdtags.read_psdtags(fh, psdformat, /, length, *, unknown=True, align=2)

Return list of tags from open file.

Parameters:
  • fh (BinaryIO)

  • psdformat (PsdFormat)

  • length (int)

  • unknown (bool)

  • align (int)

Return type:

list[PsdKeyABC]

psdtags.read_tifftag(filename, tag, /, pageindex=0)

Return tag value from TIFF file.

Parameters:
  • filename (os.PathLike[Any] | str)

  • tag (int | str)

  • pageindex (int)

Return type:

Any

psdtags.write_psdblocks(fh, /, *blocks)

Write sequence of blocks to open file.

Parameters:
Return type:

int

psdtags.write_psdtags(fh, psdformat, /, compression, maxworkers, align, *, unknown=True, tags)

Write sequence of tags to open file.

Parameters:
Return type:

int

psdtags.REPR_MAXLEN

Maximum length of bytes to show in repr().

psdtags.descriptor

Experimental Photoshop descriptor parsing and serialization.

This implementation is experimental and incomplete. It is not used automatically when reading or writing TIFF tags. Its API and roundtrip behavior are not guaranteed.

The PsdDescriptor and PsdDescriptorBlock classes parse descriptors in layer tagged blocks and image resource blocks. They have the same interface as the opaque psdtags.PsdDescriptor and psdtags.PsdDescriptorBlock classes. Unlike the opaque class, PsdDescriptor tags are not skipped when reading with unknown=False.

To enable experimental descriptor parsing in psdtags, set the PSDTAGS_DESCRIPTOR_PARSING=1 environment variable.

class psdtags.descriptor.PsdDescriptor(key, psdformat, descriptor, prefix=b'', suffix=b'')

Bases: PsdKeyABC

Tagged block containing a versioned descriptor structure.

Drop-in replacement for the opaque psdtags.PsdDescriptor. The 4-byte fields preceding the descriptor version are stored in big-endian order in prefix. Trailing data and data that cannot be parsed are kept as opaque bytes in suffix and prefix, and cannot be converted to another byte order. Re-serialized descriptors are not guaranteed to be byte-identical.

Parameters:
key: PsdKey
psdformat: PsdFormat
descriptor: PsdDescriptorStruct | None
prefix: bytes = b''
suffix: bytes = b''
VERSION: ClassVar[int] = 16
classmethod read(fh, psdformat, key, /, length)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance values to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, key, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.descriptor.PsdDescriptorAlias(value)

Bases: PsdDescriptorRaw

Descriptor alias (file reference) value.

Parameters:

value (bytes)

type: PsdDescriptorType = b'alis'
classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

Self

classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

write(fh, psdformat, /)

Write instance to open file.

Parameters:
Return type:

int

value: bytes
class psdtags.descriptor.PsdDescriptorBlock(resourceid, descriptor, name='', prefix=b'', suffix=b'')

Bases: PsdResourceBlockABC

Image resource block containing a versioned descriptor structure.

Drop-in replacement for the opaque psdtags.PsdDescriptorBlock. Trailing data and data that cannot be parsed are kept as opaque bytes in suffix and prefix. Re-serialized descriptors are not guaranteed to be byte-identical.

Parameters:
resourceid: PsdResourceId
descriptor: PsdDescriptorStruct | None
name: str = ''
prefix: bytes = b''
suffix: bytes = b''
VERSION: ClassVar[int] = 16
classmethod read(fh, psdformat, resourceid, /, name, length)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance values to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, resourceid, /, name)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.descriptor.PsdDescriptorBool(value)

Bases: PsdDescriptorValueABC

Descriptor boolean value.

Parameters:

value (bool)

value: bool
type: PsdDescriptorType = b'bool'
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.descriptor.PsdDescriptorClass(name, classid)

Bases: PsdDescriptorValueABC

Descriptor class value.

Parameters:
  • name (str)

  • classid (PsdIdType)

name: str
classid: PsdIdType
type: PsdDescriptorType = b'type'
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.descriptor.PsdDescriptorEnum(value, typeid)

Bases: PsdDescriptorValueABC

Descriptor enumerated value.

Parameters:
  • value (PsdIdType)

  • typeid (PsdIdType)

value: PsdIdType
typeid: PsdIdType
type: PsdDescriptorType = b'enum'
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.descriptor.PsdDescriptorFloat(value)

Bases: PsdDescriptorValueABC

Descriptor double (64-bit float) value.

Parameters:

value (float)

value: float
type: PsdDescriptorType = b'doub'
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.descriptor.PsdDescriptorFloatUnit(value, unit)

Bases: PsdDescriptorValueABC

Descriptor unit float value.

Parameters:
value: float
unit: PsdUnitType
type: PsdDescriptorType = b'UntF'
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.descriptor.PsdDescriptorFloatUnits(values, unit)

Bases: PsdDescriptorValueABC

Descriptor array of unit float values.

Parameters:
values: list[float]
unit: PsdUnitType
type: PsdDescriptorType = b'UnFl'
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.descriptor.PsdDescriptorGlobalClass(name, classid)

Bases: PsdDescriptorClass

Descriptor global class value.

Parameters:
  • name (str)

  • classid (PsdIdType)

type: PsdDescriptorType = b'GlbC'
classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

Self

classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

write(fh, psdformat, /)

Write instance to open file.

Parameters:
Return type:

int

name: str
classid: PsdIdType
class psdtags.descriptor.PsdDescriptorGlobalObject(classid, items, name='')

Bases: PsdDescriptorStruct

Global object descriptor structure.

Parameters:
type: PsdDescriptorType = b'GlbO'
classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

Self

name: str = ''
classmethod read(fh, psdformat, /, *, version=0)

Return instance from open file.

Parameters:
  • fh (BinaryIO)

  • psdformat (PsdFormat)

  • version (int)

Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

write(fh, psdformat, /, *, version=0)

Write descriptor structure to file.

Parameters:
  • fh (BinaryIO)

  • psdformat (PsdFormat)

  • version (int)

Return type:

int

classid: PsdIdType
items: dict[PsdIdType, PsdDescriptorValueABC]
class psdtags.descriptor.PsdDescriptorInt(value)

Bases: PsdDescriptorValueABC

Descriptor 32-bit signed integer value.

Parameters:

value (int)

value: int
type: PsdDescriptorType = b'long'
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.descriptor.PsdDescriptorList(items)

Bases: PsdDescriptorValueABC

Descriptor list value.

Parameters:

items (list[PsdDescriptorValueABC])

items: list[PsdDescriptorValueABC]
type: PsdDescriptorType = b'VlLs'
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.descriptor.PsdDescriptorLong(value)

Bases: PsdDescriptorValueABC

Descriptor 64-bit signed integer value.

Parameters:

value (int)

value: int
type: PsdDescriptorType = b'comp'
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.descriptor.PsdDescriptorObjectArray(classid, items, name='', count=0)

Bases: PsdDescriptorStruct

Object array structure (undocumented).

Parameters:
count: int = 0
type: PsdDescriptorType = b'ObAr'
classmethod read(fh, psdformat, /, *, version=0)

Return instance from open file.

Parameters:
  • fh (BinaryIO)

  • psdformat (PsdFormat)

  • version (int)

Return type:

Self

write(fh, psdformat, /, *, version=0)

Write object array to open file.

Parameters:
  • fh (BinaryIO)

  • psdformat (PsdFormat)

  • version (int)

Return type:

int

classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

Self

name: str = ''
tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

classid: PsdIdType
items: dict[PsdIdType, PsdDescriptorValueABC]
class psdtags.descriptor.PsdDescriptorPath(value)

Bases: PsdDescriptorRaw

Descriptor path value (undocumented).

Parameters:

value (bytes)

type: PsdDescriptorType = b'Pth '
classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

Self

classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

write(fh, psdformat, /)

Write instance to open file.

Parameters:
Return type:

int

value: bytes
class psdtags.descriptor.PsdDescriptorRaw(value)

Bases: PsdDescriptorValueABC

Descriptor raw data value.

Parameters:

value (bytes)

value: bytes
type: PsdDescriptorType = b'tdta'
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.descriptor.PsdDescriptorReference(items)

Bases: PsdDescriptorValueABC

Reference value.

Parameters:

items (list[PsdReferenceItemABC])

items: list[PsdReferenceItemABC]
type: PsdDescriptorType = b'obj '
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.descriptor.PsdDescriptorString(value)

Bases: PsdDescriptorValueABC

Descriptor Unicode string value.

Parameters:

value (str)

value: str
type: PsdDescriptorType = b'TEXT'
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.descriptor.PsdDescriptorStruct(classid, items, name='')

Bases: PsdDescriptorValueABC

Descriptor structure.

Descriptors are used to serialize general Photoshop data objects.

Parameters:
classid: PsdIdType
items: dict[PsdIdType, PsdDescriptorValueABC]
name: str = ''
type: PsdDescriptorType = b'Objc'
classmethod read(fh, psdformat, /, *, version=0)

Return instance from open file.

Parameters:
  • fh (BinaryIO)

  • psdformat (PsdFormat)

  • version (int)

Return type:

Self

write(fh, psdformat, /, *, version=0)

Write descriptor structure to file.

Parameters:
  • fh (BinaryIO)

  • psdformat (PsdFormat)

  • version (int)

Return type:

int

classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.descriptor.PsdDescriptorType(*values)

Bases: BytesEnum

Descriptor value types.

REFERENCE = b'obj '
DESCRIPTOR = b'Objc'
LIST = b'VlLs'
DOUBLE = b'doub'
UNIT_FLOAT = b'UntF'
STRING = b'TEXT'
ENUMERATED = b'enum'
INTEGER = b'long'
LARGE_INTEGER = b'comp'
BOOLEAN = b'bool'
GLOBAL_OBJECT = b'GlbO'
CLASS = b'type'
GLOBAL_CLASS = b'GlbC'
ALIAS = b'alis'
RAW_DATA = b'tdta'
UNIT_FLOATS = b'UnFl'
OBJECT_ARRAY = b'ObAr'
PATH = b'Pth '
tobytes(byteorder='>')

Return enum value as bytes.

Parameters:

byteorder (str)

Return type:

bytes

write(fh, byteorder='>', /)

Write enum value to open file.

Parameters:
  • fh (BinaryIO)

  • byteorder (str)

Return type:

int

value: bytes
class psdtags.descriptor.PsdDescriptorValueABC

Bases: object

Descriptor value abstract base class.

type: PsdDescriptorType
abstractmethod classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

abstractmethod write(fh, psdformat, /)

Write instance to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

Self

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.descriptor.PsdIdString(value)

Bases: object

ID string of either 4 bytes or ASCII string.

Parameters:

value (str | bytes)

value: str | bytes
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write ID string to open file.

Parameters:
Return type:

int

class psdtags.descriptor.PsdReferenceClass(name, classid)

Bases: PsdReferenceItemABC

Class reference item.

Parameters:
  • name (str)

  • classid (PsdIdType)

name: str
classid: PsdIdType
type: PsdReferenceType = b'Clss'
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance to open file.

Parameters:
Return type:

int

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.descriptor.PsdReferenceEnumerated(name, classid, typeid, value)

Bases: PsdReferenceItemABC

Enumerated reference item.

Parameters:
  • name (str)

  • classid (PsdIdType)

  • typeid (PsdIdType)

  • value (PsdIdType)

name: str
classid: PsdIdType
typeid: PsdIdType
value: PsdIdType
type: PsdReferenceType = b'Enmr'
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance to open file.

Parameters:
Return type:

int

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.descriptor.PsdReferenceIdentifier(value)

Bases: PsdReferenceItemABC

Identifier reference item.

Parameters:

value (int)

value: int
type: PsdReferenceType = b'Idnt'
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance to open file.

Parameters:
Return type:

int

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.descriptor.PsdReferenceIndex(value)

Bases: PsdReferenceItemABC

Index reference item.

Parameters:

value (int)

value: int
type: PsdReferenceType = b'indx'
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance to open file.

Parameters:
Return type:

int

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.descriptor.PsdReferenceItemABC

Bases: object

Abstract base class for reference items.

type: PsdReferenceType
abstractmethod classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

abstractmethod write(fh, psdformat, /)

Write value to open file.

Parameters:
Return type:

int

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.descriptor.PsdReferenceName(name, classid, value)

Bases: PsdReferenceItemABC

Name reference item.

Parameters:
  • name (str)

  • classid (PsdIdType)

  • value (str)

name: str
classid: PsdIdType
value: str
type: PsdReferenceType = b'name'
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance to open file.

Parameters:
Return type:

int

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.descriptor.PsdReferenceOffset(name, classid, offset)

Bases: PsdReferenceItemABC

Offset reference item.

Parameters:
  • name (str)

  • classid (PsdIdType)

  • offset (int)

name: str
classid: PsdIdType
offset: int
type: PsdReferenceType = b'rele'
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance to open file.

Parameters:
Return type:

int

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.descriptor.PsdReferenceProperty(name, classid, keyid)

Bases: PsdReferenceItemABC

Property reference item.

Parameters:
  • name (str)

  • classid (PsdIdType)

  • keyid (PsdIdType)

name: str
classid: PsdIdType
keyid: PsdIdType
type: PsdReferenceType = b'prop'
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

Self

write(fh, psdformat, /)

Write instance to open file.

Parameters:
Return type:

int

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

class psdtags.descriptor.PsdReferenceType(*values)

Bases: BytesEnum

Reference item types.

PROPERTY = b'prop'
CLASS = b'Clss'
ENUMERATED = b'Enmr'
OFFSET = b'rele'
IDENTIFIER = b'Idnt'
INDEX = b'indx'
NAME = b'name'
tobytes(byteorder='>')

Return enum value as bytes.

Parameters:

byteorder (str)

Return type:

bytes

write(fh, byteorder='>', /)

Write enum value to open file.

Parameters:
  • fh (BinaryIO)

  • byteorder (str)

Return type:

int

value: bytes
class psdtags.descriptor.PsdUnitType(*values)

Bases: BytesEnum

Unit float types.

ANGLE = b'#Ang'
DENSITY = b'#Rsl'
DISTANCE = b'#Rlt'
NONE = b'#Nne'
PERCENT = b'#Prc'
PIXELS = b'#Pxl'
POINTS = b'#Pnt'
MILLIMETERS = b'#Mlm'
tobytes(byteorder='>')

Return enum value as bytes.

Parameters:

byteorder (str)

Return type:

bytes

write(fh, byteorder='>', /)

Write enum value to open file.

Parameters:
  • fh (BinaryIO)

  • byteorder (str)

Return type:

int

value: bytes