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.1.29

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 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.11.9, 3.12.10, 3.13.11, 3.14.2 64-bit

  • NumPy 2.4.1

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

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

  • Matplotlib 3.10.8 (required for plotting)

Revisions

2026.1.29

  • Fix code review issues.

2026.1.8

  • Improve code quality.

2025.12.12

  • Make boolean and optional parameters keyword-only (breaking).

2025.9.19

  • Write MTrn key before layers (#17).

2025.9.15

  • Add CAI, GENI, and OCIO keys.

  • Drop support for Python 3.10.

2025.5.10

  • Support Python 3.14.

2025.1.1

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.

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:

>>> 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:

>>> 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:

PsdBoolean

write(fh, psdformat, /)

Write boolean to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, key, /)

Return instance from bytes.

Parameters:
Return type:

PsdKeyABC

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
classmethod read(fh, psdformat, resourceid, /, name, length)

Return instance from open file.

Parameters:
Return type:

PsdBytesBlock

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:

PsdResourceBlockABC

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
classmethod read(fh, psdformat, /)

Return instance from open file.

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

Parameters:
Return type:

PsdChannel

classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

PsdChannel

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
classmethod read(fh, psdformat, resourceid, /, name, length)

Return instance from open file.

Parameters:
Return type:

PsdColorBlock

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:

PsdResourceBlockABC

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.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:

PsdEmpty

classmethod frombytes(data, psdformat, key, /)

Return instance from bytes.

Parameters:
Return type:

PsdEmpty

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:

PsdExposure

write(fh, psdformat, /)

Write exposure to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, key, /)

Return instance from bytes.

Parameters:
Return type:

PsdKeyABC

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
key: PsdKey = b'FMsk'
classmethod read(fh, psdformat, key, /, length)

Return instance from open file.

Parameters:
Return type:

PsdFilterMask

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:

PsdKeyABC

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

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:

PsdInteger

write(fh, psdformat, /)

Write integer to open file.

Parameters:
Return type:

int

classmethod frombytes(data, psdformat, key, /)

Return instance from bytes.

Parameters:
Return type:

PsdKeyABC

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:

PsdKeyABC

classmethod frombytes(data, psdformat, key, /)

Return instance from bytes.

Parameters:
Return type:

PsdKeyABC

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=None, 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
blendmode: PsdBlendMode = b'norm'
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:

PsdLayer

classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

PsdLayer

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)

flags: PsdLayerMaskFlag = 0
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

PsdLayerMask

classmethod frombytes(data, psdformat, /)

Return instance from bytes.

Parameters:
Return type:

PsdLayerMask

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]
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:

PsdLayers

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

Return instance from bytes.

Parameters:
Return type:

PsdLayers

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
classmethod read(fh, psdformat)

Return metadata setting from open file.

Parameters:
Return type:

PsdMetadataSetting

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:

PsdMetadataSettings

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:

PsdKeyABC

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:

PsdPascalString

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
classmethod read(fh, psdformat, resourceid, /, name, length)

Return instance from open file.

Parameters:
Return type:

PsdPascalStringBlock

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:

PsdResourceBlockABC

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]
classmethod read(fh, psdformat, resourceid, /, name, length)

Return instance from open file.

Parameters:
Return type:

PsdPascalStringsBlock

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:

PsdResourceBlockABC

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

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

Bases: PsdKeyABC

Patterns (Photoshop 6.0 and CS 8.0).

Parameters:
key: PsdKey
imagemode: PsdImageMode
name: str
guid: str
data: PsdVirtualMemoryArrayList
point: PsdPoint
classmethod read(fh, psdformat, key, /, length)

Return instance from open file.

Parameters:
Return type:

PsdPatterns

write(fh, psdformat, /)

Write patterns to open file.

Parameters:
Return type:

int

asarray(*, planar=False)

Return channel image data.

Parameters:

planar (bool)

Return type:

NDArray[Any]

classmethod frombytes(data, psdformat, key, /)

Return instance from bytes.

Parameters:
Return type:

PsdKeyABC

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:

PsdReferencePoint

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:

PsdKeyABC

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:

PsdResourceBlockABC

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

Return instance from bytes.

Parameters:
Return type:

PsdResourceBlockABC

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
key: PsdKey = b'lsct'
classmethod read(fh, psdformat, key, /, length)

Return instance from open file.

Parameters:
Return type:

PsdSectionDividerSetting

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:

PsdKeyABC

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:

PsdSheetColorSetting

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:

PsdKeyABC

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:

PsdString

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:

PsdKeyABC

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
classmethod read(fh, psdformat, resourceid, /, name, length)

Return instance from open file.

Parameters:
Return type:

PsdStringBlock

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:

PsdResourceBlockABC

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]
classmethod read(fh, psdformat, resourceid, /, name, length)

Return instance from open file.

Parameters:
Return type:

PsdStringsBlock

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:

PsdResourceBlockABC

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:

PsdTextEngineData

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:

PsdKeyABC

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)

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

Return instance from open file.

Parameters:
Return type:

PsdThumbnailBlock

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:

PsdResourceBlockABC

tobytes(psdformat, /)

Return instance values as bytes.

Parameters:

psdformat (PsdFormat)

Return type:

bytes

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:

PsdUnicodeString

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:

PsdUnknown

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

Return instance from open file.

Parameters:
Return type:

PsdUnknown

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
key: PsdKey = b'LMsk'
classmethod read(fh, psdformat, key, /, length)

Return instance from open file.

Parameters:
Return type:

PsdUserMask

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:

PsdKeyABC

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
classmethod read(fh, psdformat, resourceid, /, name, length)

Return instance from open file.

Parameters:
Return type:

PsdVersionBlock

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:

PsdResourceBlockABC

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)

compression: PsdCompressionType = 0
classmethod read(fh, psdformat, /)

Return instance from open file.

Parameters:
Return type:

PsdVirtualMemoryArray

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:

PsdVirtualMemoryArrayList

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:

PsdWord

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:

PsdKeyABC

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]
classmethod read(fh, length, name=None)

Return instance from open file.

Parameters:
  • fh (BinaryIO)

  • length (int)

  • name (str | None)

Return type:

TiffImageResources

classmethod frombytes(data, name=None)

Return instance from ImageResources tag value.

Parameters:
  • data (bytes)

  • name (str | None)

Return type:

TiffImageResources

classmethod fromtiff(filename, /, pageindex=0)

Return instance from ImageResources tag in TIFF file.

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

  • pageindex (int)

Return type:

TiffImageResources

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]
classmethod read(fh, /, name=None, *, unknown=True)

Return instance from open file.

Parameters:
  • fh (BinaryIO)

  • name (str | None)

  • unknown (bool)

Return type:

TiffImageSourceData

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

Return instance from bytes.

Parameters:
  • data (bytes)

  • name (str | None)

  • unknown (bool)

Return type:

TiffImageSourceData

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

Return instance from TIFF file.

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

  • pageindex (int)

  • unknown (bool)

Return type:

TiffImageSourceData

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)

  • 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().