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__ = '2026.1.29'

Psdtags version string.

class psdtags.PsdBlendMode(*values)

Bases: BytesEnum

Blend modes.

__new__(value)
class psdtags.PsdBoolean(key, value)

Bases: PsdKeyABC

Boolean.

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

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(key, value)
Parameters:
Return type:

None

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

Bases: PsdResourceBlockABC

Image resource blocks stored as opaque bytes.

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

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(resourceid, value, name='')
Parameters:
Return type:

None

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

Bases: object

ChannelInfo and ChannelImageData.

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

__hash__()

Return hash(self).

Return type:

int

__eq__(other)

Return self==value.

Parameters:

other (object)

Return type:

bool

__repr__()

Return repr(self).

Return type:

str

__init__(channelid, compression=PsdCompressionType.RAW, data=None, _data_length=0)
Parameters:
Return type:

None

__weakref__

list of weak references to the object

class psdtags.PsdChannelId(*values)

Bases: IntEnum

Channel types.

__format__(format_spec, /)

Convert to a string according to format_spec.

__new__(value)
class psdtags.PsdClippingType(*values)

Bases: IntEnum

Clipping types.

__format__(format_spec, /)

Convert to a string according to format_spec.

__new__(value)
class psdtags.PsdColorBlock(resourceid, colorspace, components=(0, 0, 0, 0), name='')

Bases: PsdResourceBlockABC

Color structure.

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

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(resourceid, colorspace, components=(0, 0, 0, 0), name='')
Parameters:
Return type:

None

class psdtags.PsdColorSpaceType(*values)

Bases: IntEnum

Color space types.

__format__(format_spec, /)

Convert to a string according to format_spec.

__new__(value)
class psdtags.PsdColorType(*values)

Bases: IntEnum

Color IDs used by sheet color setting structure.

__format__(format_spec, /)

Convert to a string according to format_spec.

__new__(value)
class psdtags.PsdCompressionType(*values)

Bases: IntEnum

Image compression types.

__format__(format_spec, /)

Convert to a string according to format_spec.

__new__(value)
class psdtags.PsdEmpty(key)

Bases: PsdKeyABC

Empty structure, no data associated with key.

Parameters:

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

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(key)
Parameters:

key (PsdKey)

Return type:

None

class psdtags.PsdExposure(exposure, offset, gamma)

Bases: PsdKeyABC

Exposure.

Parameters:
  • exposure (float)

  • offset (float)

  • gamma (float)

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

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(exposure, offset, gamma)
Parameters:
  • exposure (float)

  • offset (float)

  • gamma (float)

Return type:

None

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)

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

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(colorspace, components=(0, 0, 0, 0), opacity=0)
Parameters:
  • colorspace (PsdColorSpaceType)

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

  • opacity (int)

Return type:

None

class psdtags.PsdFormat(*values)

Bases: bytes, Enum

PSD format.

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

__new__(value)
__repr__()

Return repr(self).

__str__()

Return str(self).

class psdtags.PsdImageMode(*values)

Bases: IntEnum

Image modes.

__format__(format_spec, /)

Convert to a string according to format_spec.

__new__(value)
class psdtags.PsdInteger(key, value)

Bases: PsdKeyABC

4 Byte Integer.

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

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(key, value)
Parameters:
Return type:

None

class psdtags.PsdKey(*values)

Bases: BytesEnum

Keys of tagged structures.

__new__(value)
class psdtags.PsdKeyABC

Bases: object

Abstract base class for structures with key.

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

__repr__()

Return repr(self).

Return type:

str

__weakref__

list of weak references to the object

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

__hash__()

Return hash(self).

Return type:

int

__eq__(other)

Return self==value.

Parameters:

other (object)

Return type:

bool

__repr__()

Return repr(self).

Return type:

str

__init__(name, channels, rectangle, mask=None, opacity=255, blendmode=PsdBlendMode.NORMAL, blending_ranges=(), clipping=PsdClippingType.BASE, flags=<PsdLayerFlag.BASE: 0>, info=<factory>)
Parameters:
Return type:

None

__weakref__

list of weak references to the object

class psdtags.PsdLayerFlag(*values)

Bases: IntFlag

Layer record flags.

__format__(format_spec, /)

Convert to a string according to format_spec.

__or__(other)

Return self|value.

__and__(other)

Return self&value.

__xor__(other)

Return self^value.

__ror__(other)

Return value|self.

__rand__(other)

Return value&self.

__rxor__(other)

Return value^self.

__invert__()

~self

__new__(value)
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)

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.

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(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)
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)

Return type:

None

__weakref__

list of weak references to the object

class psdtags.PsdLayerMaskFlag(*values)

Bases: IntFlag

Layer mask flags.

__format__(format_spec, /)

Convert to a string according to format_spec.

__or__(other)

Return self|value.

__and__(other)

Return self&value.

__xor__(other)

Return self^value.

__ror__(other)

Return value|self.

__rand__(other)

Return value&self.

__rxor__(other)

Return value^self.

__invert__()

~self

__new__(value)
class psdtags.PsdLayerMaskParameterFlag(*values)

Bases: IntFlag

Layer mask parameters.

__format__(format_spec, /)

Convert to a string according to format_spec.

__or__(other)

Return self|value.

__and__(other)

Return self&value.

__xor__(other)

Return self^value.

__ror__(other)

Return value|self.

__rand__(other)

Return value&self.

__rxor__(other)

Return value^self.

__invert__()

~self

__new__(value)
class psdtags.PsdLayers(key, layers=<factory>, has_transparency=False)

Bases: PsdKeyABC

Sequence of PsdLayer.

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

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(key, layers=<factory>, has_transparency=False)
Parameters:
Return type:

None

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

Bases: object

Metadata setting item.

Parameters:
  • signature (PsdFormat)

  • key (bytes)

  • data (bytes)

  • copyonsheet (bool)

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

__hash__()

Return hash(self).

Return type:

int

__eq__(other)

Return self==value.

Parameters:

other (object)

Return type:

bool

__repr__()

Return repr(self).

Return type:

str

__init__(signature, key, data=b'', copyonsheet=False)
Parameters:
  • signature (PsdFormat)

  • key (bytes)

  • data (bytes)

  • copyonsheet (bool)

Return type:

None

__weakref__

list of weak references to the object

class psdtags.PsdMetadataSettings(items=<factory>)

Bases: PsdKeyABC

Metadata setting (Photoshop 6.0).

Parameters:

items (list[PsdMetadataSetting])

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

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(items=<factory>)
Parameters:

items (list[PsdMetadataSetting])

Return type:

None

class psdtags.PsdPascalString(value)

Bases: object

Pascal string.

Parameters:

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

__str__()

Return str(self).

Return type:

str

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(value)
Parameters:

value (str)

Return type:

None

__weakref__

list of weak references to the object

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

Bases: PsdResourceBlockABC

Pascal string.

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

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(resourceid, value, name='')
Parameters:
Return type:

None

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

Bases: PsdResourceBlockABC

Series of Pascal strings.

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

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(resourceid, values, name='')
Parameters:
Return type:

None

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

Bases: PsdKeyABC

Patterns (Photoshop 6.0 and CS 8.0).

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

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(key, imagemode, name, guid, data, colortable=None, point=<factory>)
Parameters:
Return type:

None

class psdtags.PsdPoint(y, x)

Bases: NamedTuple

Point.

Parameters:
  • y (int)

  • x (int)

y: int

Alias for field number 0

x: int

Alias for field number 1

__repr__()

Return repr(self).

Return type:

str

__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

static __new__(_cls, y, x)

Create new instance of PsdPoint(y, x)

Parameters:
  • y (int)

  • x (int)

__replace__(**kwds)

Return a new PsdPoint object replacing specified fields with new values

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

Bases: NamedTuple

Rectangle.

Parameters:
  • top (int)

  • left (int)

  • bottom (int)

  • right (int)

top: int

Alias for field number 0

left: int

Alias for field number 1

bottom: int

Alias for field number 2

right: int

Alias for field number 3

property shape: tuple[int, int]

Height and width of rectangle.

property offset: tuple[int, int]

Top-left position of rectangle.

__repr__()

Return repr(self).

Return type:

str

__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

static __new__(_cls, top, left, bottom, right)

Create new instance of PsdRectangle(top, left, bottom, right)

Parameters:
  • top (int)

  • left (int)

  • bottom (int)

  • right (int)

__replace__(**kwds)

Return a new PsdRectangle object replacing specified fields with new values

class psdtags.PsdReferencePoint(x, y)

Bases: PsdKeyABC

Reference point.

Parameters:
  • x (float)

  • y (float)

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

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(x, y)
Parameters:
  • x (float)

  • y (float)

Return type:

None

class psdtags.PsdResourceBlockABC

Bases: object

Abstract base class for image resource block data.

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

__repr__()

Return repr(self).

Return type:

str

__weakref__

list of weak references to the object

class psdtags.PsdResourceId(*values)

Bases: IntEnum

Image resource IDs.

__format__(format_spec, /)

Convert to a string according to format_spec.

__new__(value)
class psdtags.PsdSectionDividerSetting(kind, blendmode=None, subtype=None)

Bases: PsdKeyABC

Section divider setting (Photoshop 6.0).

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

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(kind, blendmode=None, subtype=None)
Parameters:
Return type:

None

class psdtags.PsdSectionDividerType(*values)

Bases: IntEnum

Section divider setting types.

__format__(format_spec, /)

Convert to a string according to format_spec.

__new__(value)
class psdtags.PsdSheetColorSetting(color)

Bases: PsdKeyABC

Sheet color setting (Photoshop 6.0).

Parameters:

color (PsdColorType)

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

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(color)
Parameters:

color (PsdColorType)

Return type:

None

class psdtags.PsdString(key, value)

Bases: PsdKeyABC

Unicode string.

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

__str__()

Return str(self).

Return type:

str

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(key, value)
Parameters:
Return type:

None

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

Bases: PsdResourceBlockABC

Unicode string.

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

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(resourceid, value, name='')
Parameters:
Return type:

None

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

Bases: PsdResourceBlockABC

Series of Unicode strings.

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

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(resourceid, values, name='')
Parameters:
Return type:

None

class psdtags.PsdTextEngineData(data)

Bases: PsdKeyABC

Text Engine Data (Photoshop CS3).

Parameters:

data (bytes)

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

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(data)
Parameters:

data (bytes)

Return type:

None

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:

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.

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(resourceid, format, width, height, rawdata, name='')
Parameters:
  • resourceid (PsdResourceId)

  • format (PsdThumbnailFormat)

  • width (int)

  • height (int)

  • rawdata (bytes)

  • name (str)

Return type:

None

class psdtags.PsdUnicodeString(value)

Bases: object

Unicode string.

Parameters:

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

__str__()

Return str(self).

Return type:

str

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(value)
Parameters:

value (str)

Return type:

None

__weakref__

list of weak references to the object

class psdtags.PsdUnknown(key, psdformat, value)

Bases: PsdKeyABC

Unknown keys stored as opaque bytes.

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

__hash__()

Return hash(self).

Return type:

int

__eq__(other)

Return self==value.

Parameters:

other (object)

Return type:

bool

__repr__()

Return repr(self).

Return type:

str

__init__(key, psdformat, value)
Parameters:
Return type:

None

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)

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

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(colorspace=PsdColorSpaceType.UNKNOWN, components=(0, 0, 0, 0), opacity=0, flag=128)
Parameters:
  • colorspace (PsdColorSpaceType)

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

  • opacity (int)

  • flag (int)

Return type:

None

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)

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

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(resourceid, version, file_version, writer_name, reader_name, has_real_merged_data, name='')
Parameters:
  • resourceid (PsdResourceId)

  • version (int)

  • file_version (int)

  • writer_name (str)

  • reader_name (str)

  • has_real_merged_data (bool)

  • name (str)

Return type:

None

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)

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.

__hash__()

Return hash(self).

Return type:

int

__eq__(other)

Return self==value.

Parameters:

other (object)

Return type:

bool

__repr__()

Return repr(self).

Return type:

str

__init__(iswritten=False, depth=None, rectangle=None, pixeldepth=None, compression=PsdCompressionType.RAW, data=None)
Parameters:
  • iswritten (bool)

  • depth (int | None)

  • rectangle (PsdRectangle | None)

  • pixeldepth (int | None)

  • compression (PsdCompressionType)

  • data (NDArray[Any] | None)

Return type:

None

__weakref__

list of weak references to the object

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

Bases: object

Virtual memory array list.

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

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(rectangle, channels=<factory>)
Parameters:
Return type:

None

__weakref__

list of weak references to the object

class psdtags.PsdWord(key, value)

Bases: PsdKeyABC

Four bytes.

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

__repr__()

Return repr(self).

Return type:

str

__eq__(other)

Return self==value.

__init__(key, value)
Parameters:
Return type:

None

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

Bases: object

TIFF ImageResources tag #34377.

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

__hash__()

Return hash(self).

Return type:

int

__eq__(other)

Return self==value.

Parameters:

other (object)

Return type:

bool

__repr__()

Return repr(self).

Return type:

str

__init__(psdformat, blocks, name=None)
Parameters:
Return type:

None

__weakref__

list of weak references to the object

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

Bases: object

TIFF ImageSourceData tag #37724.

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

__hash__()

Return hash(self).

Return type:

int

__eq__(other)

Return self==value.

Parameters:

other (object)

Return type:

bool

__repr__()

Return repr(self).

Return type:

str

__init__(psdformat, layers, usermask, info=<factory>, name=None)
Parameters:
Return type:

None

__weakref__

list of weak references to the object

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 = 24

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4