https://github.com/cgohlke/psdtags

Read and write layered TIFF ImageSourceData and ImageResources tags.

https://github.com/cgohlke/psdtags

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
    1 of 2 committers (50.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.4%) to scientific vocabulary

Keywords

format-reader photoshop psd python tiff
Last synced: 5 months ago · JSON representation

Repository

Read and write layered TIFF ImageSourceData and ImageResources tags.

Basic Info
Statistics
  • Stars: 27
  • Watchers: 4
  • Forks: 3
  • Open Issues: 0
  • Releases: 10
Topics
format-reader photoshop psd python tiff
Created about 4 years ago · Last pushed 10 months ago
Metadata Files
Readme License

README.rst

..
  This file is generated by setup.py

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: 2025.5.10
: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.10.11, 3.11.9, 3.12.10, 3.13.3 64-bit
- `NumPy `_ 2.2.5
- `Imagecodecs `_ 2025.3.30
  (required for compressing/decompressing image data)
- `Tifffile `_ 2025.5.10
  (required for reading/writing tags from/to TIFF files)
- `Matplotlib `_ 3.10.3
  (required for plotting)

Revisions
---------

2025.5.10

- Support Python 3.14.

2025.1.1

- Improve type hints.
- Support Python 3.13.

2024.5.24

- Fix docstring examples not correctly rendered on GitHub.

2024.2.22

- Fix reading PsdBoolean (#10).
- Fix order of PsdReferencePoint coordinates (breaking).
- Allow reading unaligned PsdLayer blending_ranges.

2024.1.15

- Fix multi-threading.

2024.1.8

- Add option to compress layer channels in multiple threads.
- Improve logging.
- Drop support for Python 3.9 and numpy < 1.23 (NEP29).

2023.8.24

- Fix channel data in layer and pattern blocks must be in big-endian order.

2023.6.15

- Use PsdThumbnailFormat enum for PsdThumbnailBlock.format.

2023.4.30

- Few API changes (breaking).
- Improve object repr.
- Drop support for Python 3.8 and numpy < 1.21 (NEP29).

2023.2.18

- Allow unknown PsdKeys (#5).

2023.2.8

- Change PsdPoint and PsdReferencePoint signatures (breaking).
- Add helper function to create composite from layers.

2022.8.25

- Update metadata.

2022.2.11

- Fix struct padding.
- Support TiffImageResources.

2022.2.2

- Various API changes (breaking).
- Handle additional layer information.
- Preserve structures of unknown format as opaque bytes.
- Add options to skip tag structures of unknown format.
- Add abstract base class for tag structures.
- Add classes for many structures.

2022.1.18

- Various API changes (breaking).
- Various fixes for writing TiffImageSourceData.
- Support filter masks.
- Add option to change channel compression on write.
- Warn when skipping ResourceKey sections.

2022.1.14

- Initial release.

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:

.. code-block:: python

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

.. code-block:: python

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

.. code-block:: python

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

.. code-block:: python

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

Owner

  • Name: Christoph Gohlke
  • Login: cgohlke
  • Kind: user
  • Location: Irvine, California

GitHub Events

Total
  • Create event: 2
  • Issues event: 1
  • Release event: 2
  • Watch event: 5
  • Issue comment event: 2
  • Push event: 2
Last Year
  • Create event: 2
  • Issues event: 1
  • Release event: 2
  • Watch event: 5
  • Issue comment event: 2
  • Push event: 2

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 55
  • Total Committers: 2
  • Avg Commits per committer: 27.5
  • Development Distribution Score (DDS): 0.273
Past Year
  • Commits: 20
  • Committers: 1
  • Avg Commits per committer: 20.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Christoph Gohlke c****e@c****m 40
Christoph Gohlke c****e@u****u 15
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 16
  • Total pull requests: 0
  • Average time to close issues: 1 day
  • Average time to close pull requests: N/A
  • Total issue authors: 13
  • Total pull request authors: 0
  • Average comments per issue: 3.13
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 4
  • Pull requests: 0
  • Average time to close issues: 1 day
  • Average time to close pull requests: N/A
  • Issue authors: 4
  • Pull request authors: 0
  • Average comments per issue: 1.25
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • widdowson (3)
  • jindili (2)
  • konri (1)
  • dadwjiodjwad (1)
  • schwarzwals (1)
  • eroux (1)
  • VincenzoCiv (1)
  • StefanBaar (1)
  • Nomination-NRB (1)
  • YiXinChenChen (1)
  • tlxfif (1)
  • yuriki (1)
  • kmanimurugan (1)
Pull Request Authors
Top Labels
Issue Labels
question (10) enhancement (1)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 1,489 last-month
  • Total dependent packages: 1
  • Total dependent repositories: 1
  • Total versions: 17
  • Total maintainers: 1
pypi.org: psdtags

Read and write layered TIFF ImageSourceData and ImageResources tags

  • Versions: 17
  • Dependent Packages: 1
  • Dependent Repositories: 1
  • Downloads: 1,489 Last month
Rankings
Dependent packages count: 10.0%
Stargazers count: 16.0%
Average: 16.9%
Downloads: 17.3%
Forks count: 19.2%
Dependent repos count: 21.8%
Maintainers (1)
Last synced: 6 months ago

Dependencies

setup.py pypi
  • numpy >=1.19.2