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:
- Organization:
Laboratory for Fluorescence Dynamics, University of California, Irvine
- License:
BSD 3-Clause
- Version:
2022.1.18
- Status:
Alpha
Requirements
This release has been tested with the following requirements and dependencies (other versions may work):
Imagecodecs 2021.11.20 (optional)
Tifffile 2021.11.2 (optional)
Matplotlib 3.4.3 (optional)
Revisions
- 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 module 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.
Examples
Read the ImageSourceData tag value from a layered TIFF file and iterate over all the channels:
>>> psd = TiffImageSourceData.fromtiff('layered.tif') >>> for layer in psd.layers: ... layer.name ... for channel in layer.channels: ... ch = channel.data # a numpy array 'Background' 'Reflect1' 'Reflect2' 'image' 'Layer 1' 'ORight' 'I' 'IShadow' 'O'
Write the image and ImageSourceData to a new layered TIFF file:
>>> from tifffile import imread, imwrite >>> image = imread('layered.tif') >>> imwrite( ... '_layered.tif', ... image, ... byteorder=psd.byteorder, # must match ImageSourceData ... photometric='rgb', # must match ImageSourceData ... metadata=None, # do not write any tifffile specific metadata ... extratags=[psd.tifftag()], ... )
Verify that the new layered TIFF file contains readable ImageSourceData:
>>> assert psd == TiffImageSourceData.fromtiff('_layered.tif')
To view the layer and mask information in a layered TIFF file from a command line, run:
python -m psdtags layered.tif
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for psdtags-2022.1.18-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf06442d31793e6be791857ce4cdf7bce3731ec2fd66db2c635e5fb51201fe8f |
|
MD5 | 78a33d51fa3a95cde7f78ad28ed66d23 |
|
BLAKE2b-256 | 3dd6d02d31096f85b5d9de5733dc463cff749d03d9d8c07130261d8d276e98e6 |