Skip to main content

Read and write layered TIFF ImageSourceData and ImageResources tags

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

psdtags-2026.1.29.tar.gz (42.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

psdtags-2026.1.29-py3-none-any.whl (31.2 kB view details)

Uploaded Python 3

File details

Details for the file psdtags-2026.1.29.tar.gz.

File metadata

  • Download URL: psdtags-2026.1.29.tar.gz
  • Upload date:
  • Size: 42.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for psdtags-2026.1.29.tar.gz
Algorithm Hash digest
SHA256 233117d3604809ad39d6c52b18aa4befefc1524778176b1698ef080c3ddc28fe
MD5 f894e04e712b112a7f8072c853db9037
BLAKE2b-256 044405ec29e13d157ee96bfa763d4efaceeb69fe968d4bfd4754fda223bbb142

See more details on using hashes here.

File details

Details for the file psdtags-2026.1.29-py3-none-any.whl.

File metadata

  • Download URL: psdtags-2026.1.29-py3-none-any.whl
  • Upload date:
  • Size: 31.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for psdtags-2026.1.29-py3-none-any.whl
Algorithm Hash digest
SHA256 ded35c7c5bfe0f0003f3c7ba537ca6505493e7bc4b28cd73e8ff3fa76f8663b2
MD5 04695aff0c4c3e25c3e4f10a7a17eb0e
BLAKE2b-256 85690ddba19e84e751fe5052e04d12bab604fd06f05ef10e6ee4604fa368f70f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page