Skip to main content

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.

Metadata

Release files for psdtags 2026.11.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for psdtags 2026.11.1
File Size Uploaded Provenance Actions
psdtags-2026.11.1.tar.gz 50.8 kB Without provenance Details for psdtags-2026.11.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for psdtags 2026.11.1
File Interpreter ABI Platform Actions
psdtags-2026.11.1-py3-none-any.whl Python 3 none any Details for psdtags-2026.11.1-py3-none-any.whl

Total release size: 90.4 kB

Release files / psdtags-2026.11.1.tar.gz

Download URL psdtags-2026.11.1.tar.gz
Size 50.8 kB
Tags Source
SHA-256 checksum
How to use checksums
777b56e9d055b332673bfb0a5b1458b5d3602e10cafab29371754e565f0ce52f
BLAKE2b-256 checksum
How to use checksums
2f9d9ac7a6771ec6b1367ed1a80794adc7eb0d69937a48eafb3ad28cd24239bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Release files / psdtags-2026.11.1-py3-none-any.whl

Download URL psdtags-2026.11.1-py3-none-any.whl
Size 39.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5740ff0b6adffb57d20b2366fa65654a3d8b6e0552acba09b946df093590129a
BLAKE2b-256 checksum
How to use checksums
13b1b0060b5b27b0356f39bee6772c1cdd0ca3c799d77893dc92ad6e98a02f9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Security for psdtags 2026.11.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page