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:
- License:
BSD-3-Clause
- Version:
2026.1.29
- DOI:
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__¶
Psdtags version string.
- class psdtags.PsdBlendMode(*values)¶
Bases:
BytesEnumBlend modes.
- tobytes(byteorder='>')¶
Return enum value as bytes.
- Parameters:
byteorder (str)
- Return type:
bytes
- write(fh, byteorder='>', /)¶
Write enum value to open file.
- Parameters:
fh (BinaryIO)
byteorder (str)
- Return type:
int
- class psdtags.PsdBoolean(key, value)¶
Bases:
PsdKeyABCBoolean.
- Parameters:
key (PsdKey)
value (bool)
- classmethod read(fh, psdformat, key, /, length)¶
Return instance from open file.
- Parameters:
- Return type:
- write(fh, psdformat, /)¶
Write boolean to open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
- Return type:
int
- classmethod frombytes(data, psdformat, key, /)¶
Return instance from bytes.
- class psdtags.PsdBytesBlock(resourceid, value, name='')¶
Bases:
PsdResourceBlockABCImage resource blocks stored as opaque bytes.
- Parameters:
resourceid (PsdResourceId)
value (bytes)
name (str)
- classmethod read(fh, psdformat, resourceid, /, name, length)¶
Return instance from open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
resourceid (PsdResourceId)
name (str)
length (int)
- Return type:
- write(fh, psdformat, /)¶
Write instance values to open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
- Return type:
int
- classmethod frombytes(data, psdformat, resourceid, /, name)¶
Return instance from bytes.
- Parameters:
data (bytes)
psdformat (PsdFormat)
resourceid (PsdResourceId)
name (str)
- Return type:
- class psdtags.PsdChannel(channelid, compression=PsdCompressionType.RAW, data=None, _data_length=0)¶
Bases:
objectChannelInfo and ChannelImageData.
- Parameters:
channelid (PsdChannelId)
compression (PsdCompressionType)
data (NDArray[Any] | None)
_data_length (int)
- classmethod read(fh, psdformat, /)¶
Return instance from open file.
Channel image data must be read separately using
PsdChannel.read_image().- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
- Return type:
- classmethod frombytes(data, psdformat, /)¶
Return instance from bytes.
- Parameters:
data (bytes)
psdformat (PsdFormat)
- Return type:
- 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:
psdformat (PsdFormat)
compression (PsdCompressionType | None)
- Return type:
tuple[bytes, bytes]
- write(fh, psdformat, /, compression=None)¶
Write channel info record to file and return image data record.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
compression (PsdCompressionType | None)
- Return type:
bytes
- class psdtags.PsdChannelId(*values)¶
Bases:
IntEnumChannel types.
- class psdtags.PsdClippingType(*values)¶
Bases:
IntEnumClipping types.
- class psdtags.PsdColorBlock(resourceid, colorspace, components=(0, 0, 0, 0), name='')¶
Bases:
PsdResourceBlockABCColor structure.
- Parameters:
resourceid (PsdResourceId)
colorspace (PsdColorSpaceType)
components (tuple[int, int, int, int])
name (str)
- classmethod read(fh, psdformat, resourceid, /, name, length)¶
Return instance from open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
resourceid (PsdResourceId)
name (str)
length (int)
- Return type:
- write(fh, psdformat, /)¶
Write instance values to open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
- Return type:
int
- classmethod frombytes(data, psdformat, resourceid, /, name)¶
Return instance from bytes.
- Parameters:
data (bytes)
psdformat (PsdFormat)
resourceid (PsdResourceId)
name (str)
- Return type:
- class psdtags.PsdColorSpaceType(*values)¶
Bases:
IntEnumColor space types.
- class psdtags.PsdColorType(*values)¶
Bases:
IntEnumColor IDs used by sheet color setting structure.
- class psdtags.PsdCompressionType(*values)¶
Bases:
IntEnumImage compression types.
- class psdtags.PsdEmpty(key)¶
Bases:
PsdKeyABCEmpty structure, no data associated with key.
- Parameters:
key (PsdKey)
- classmethod read(fh, psdformat, key, /, length)¶
Return instance from open file.
- classmethod frombytes(data, psdformat, key, /)¶
Return instance from bytes.
- class psdtags.PsdExposure(exposure, offset, gamma)¶
Bases:
PsdKeyABCExposure.
- Parameters:
exposure (float)
offset (float)
gamma (float)
- classmethod read(fh, psdformat, key, /, length)¶
Return exposure from open file.
- Parameters:
- Return type:
- write(fh, psdformat, /)¶
Write exposure to open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
- Return type:
int
- classmethod frombytes(data, psdformat, key, /)¶
Return instance from bytes.
- class psdtags.PsdFilterMask(colorspace, components=(0, 0, 0, 0), opacity=0)¶
Bases:
PsdKeyABCFilter 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:
- tobytes(psdformat, /)¶
Return filter mask record.
- Parameters:
psdformat (PsdFormat)
- Return type:
bytes
- class psdtags.PsdFormat(*values)¶
Bases:
bytes,EnumPSD 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
- class psdtags.PsdImageMode(*values)¶
Bases:
IntEnumImage modes.
- class psdtags.PsdInteger(key, value)¶
Bases:
PsdKeyABC4 Byte Integer.
- Parameters:
key (PsdKey)
value (int)
- classmethod read(fh, psdformat, key, /, length)¶
Return instance from open file.
- Parameters:
- Return type:
- write(fh, psdformat, /)¶
Write integer to open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
- Return type:
int
- classmethod frombytes(data, psdformat, key, /)¶
Return instance from bytes.
- class psdtags.PsdKey(*values)¶
Bases:
BytesEnumKeys of tagged structures.
- tobytes(byteorder='>')¶
Return enum value as bytes.
- Parameters:
byteorder (str)
- Return type:
bytes
- write(fh, byteorder='>', /)¶
Write enum value to open file.
- Parameters:
fh (BinaryIO)
byteorder (str)
- Return type:
int
- class psdtags.PsdKeyABC¶
Bases:
objectAbstract base class for structures with key.
- abstractmethod classmethod read(fh, psdformat, key, /, length)¶
Return instance from open file.
- classmethod frombytes(data, psdformat, key, /)¶
Return instance from bytes.
- 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:
objectPSD layer record.
- Parameters:
name (str)
channels (list[PsdChannel])
rectangle (PsdRectangle)
mask (PsdLayerMask | None)
opacity (int)
blendmode (PsdBlendMode)
blending_ranges (tuple[int, ...])
clipping (PsdClippingType)
flags (PsdLayerFlag)
info (list[Any])
- classmethod read(fh, psdformat, /, *, unknown=True)¶
Return instance from open file.
Channel image data must be read separately.
- classmethod frombytes(data, psdformat, /)¶
Return instance from bytes.
- write(fh, psdformat, /, *, compression=None, unknown=True, maxworkers=1)¶
Write layer record to open file and return channel data records.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
compression (PsdCompressionType | None)
unknown (bool)
maxworkers (int)
- Return type:
bytes
- tobytes(psdformat, /, *, compression=None, unknown=True, maxworkers=1)¶
Return layer and channel data records.
- Parameters:
psdformat (PsdFormat)
compression (PsdCompressionType | None)
unknown (bool)
maxworkers (int)
- Return type:
tuple[bytes, bytes]
- asarray(*, channelid=None, planar=False)¶
Return channel image data.
- Parameters:
channelid (PsdChannelId | None)
planar (bool)
- 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.
- class psdtags.PsdLayerFlag(*values)¶
Bases:
IntFlagLayer record flags.
- 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:
objectLayer 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:
fh (BinaryIO)
psdformat (PsdFormat)
- Return type:
- classmethod frombytes(data, psdformat, /)¶
Return instance from bytes.
- Parameters:
data (bytes)
psdformat (PsdFormat)
- Return type:
- tobytes(psdformat, /)¶
Return layer mask structure.
- Parameters:
psdformat (PsdFormat)
- Return type:
bytes
- write(fh, psdformat, /)¶
Write layer mask structure to open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
- 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.
- class psdtags.PsdLayerMaskFlag(*values)¶
Bases:
IntFlagLayer mask flags.
- class psdtags.PsdLayerMaskParameterFlag(*values)¶
Bases:
IntFlagLayer mask parameters.
- class psdtags.PsdLayers(key, layers=<factory>, has_transparency=False)¶
Bases:
PsdKeyABCSequence of PsdLayer.
- classmethod read(fh, psdformat, key, /, length, *, unknown=True)¶
Return instance from open file.
- classmethod frombytes(data, psdformat, key, /, *, unknown=True)¶
Return instance from bytes.
- write(fh, psdformat, /, *, compression=None, unknown=True, maxworkers=1)¶
Write layer records and channel info data to open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
compression (PsdCompressionType | None)
unknown (bool)
maxworkers (int)
- Return type:
int
- tobytes(psdformat, /, *, compression=None, unknown=True, maxworkers=1)¶
Return layer records and channel info data as bytes.
- Parameters:
psdformat (PsdFormat)
compression (PsdCompressionType | None)
unknown (bool)
maxworkers (int)
- Return type:
bytes
- property dtype: numpy.dtype[Any]¶
Data type of layer images.
- property shape: tuple[int, int]¶
Height and width of layer images.
- class psdtags.PsdMetadataSetting(signature, key, data=b'', copyonsheet=False)¶
Bases:
objectMetadata setting item.
- Parameters:
signature (PsdFormat)
key (bytes)
data (bytes)
copyonsheet (bool)
- class psdtags.PsdMetadataSettings(items=<factory>)¶
Bases:
PsdKeyABCMetadata setting (Photoshop 6.0).
- Parameters:
items (list[PsdMetadataSetting])
- classmethod read(fh, psdformat, key, /, length)¶
Return metadata settings from open file.
- Parameters:
- Return type:
- write(fh, psdformat, /)¶
Write metadata settings to open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
- Return type:
int
- classmethod frombytes(data, psdformat, key, /)¶
Return instance from bytes.
- class psdtags.PsdPascalString(value)¶
Bases:
objectPascal string.
- Parameters:
value (str)
- classmethod read(fh, pad=1)¶
Return instance from open file.
- Parameters:
fh (BinaryIO)
pad (int)
- Return type:
- write(fh, pad=1)¶
Write Pascal string to open file.
- Parameters:
fh (BinaryIO)
pad (int)
- Return type:
int
- class psdtags.PsdPascalStringBlock(resourceid, value, name='')¶
Bases:
PsdResourceBlockABCPascal string.
- Parameters:
resourceid (PsdResourceId)
value (str)
name (str)
- classmethod read(fh, psdformat, resourceid, /, name, length)¶
Return instance from open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
resourceid (PsdResourceId)
name (str)
length (int)
- Return type:
- write(fh, psdformat, /)¶
Write Pascal string to open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
- Return type:
int
- classmethod frombytes(data, psdformat, resourceid, /, name)¶
Return instance from bytes.
- Parameters:
data (bytes)
psdformat (PsdFormat)
resourceid (PsdResourceId)
name (str)
- Return type:
- class psdtags.PsdPascalStringsBlock(resourceid, values, name='')¶
Bases:
PsdResourceBlockABCSeries of Pascal strings.
- Parameters:
resourceid (PsdResourceId)
values (list[str])
name (str)
- classmethod read(fh, psdformat, resourceid, /, name, length)¶
Return instance from open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
resourceid (PsdResourceId)
name (str)
length (int)
- Return type:
- write(fh, psdformat, /)¶
Write sequence of Pascal strings to open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
- Return type:
int
- classmethod frombytes(data, psdformat, resourceid, /, name)¶
Return instance from bytes.
- Parameters:
data (bytes)
psdformat (PsdFormat)
resourceid (PsdResourceId)
name (str)
- Return type:
- class psdtags.PsdPatterns(key, imagemode, name, guid, data, colortable=None, point=<factory>)¶
Bases:
PsdKeyABCPatterns (Photoshop 6.0 and CS 8.0).
- Parameters:
key (PsdKey)
imagemode (PsdImageMode)
name (str)
guid (str)
data (PsdVirtualMemoryArrayList)
colortable (NDArray[numpy.uint8] | None)
point (PsdPoint)
- classmethod read(fh, psdformat, key, /, length)¶
Return instance from open file.
- Parameters:
- Return type:
- write(fh, psdformat, /)¶
Write patterns to open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
- Return type:
int
- asarray(*, planar=False)¶
Return channel image data.
- Parameters:
planar (bool)
- Return type:
NDArray[Any]
- classmethod frombytes(data, psdformat, key, /)¶
Return instance from bytes.
- class psdtags.PsdPoint(y, x)¶
Bases:
NamedTuplePoint.
- Parameters:
y (int)
x (int)
- class psdtags.PsdRectangle(top, left, bottom, right)¶
Bases:
NamedTupleRectangle.
- Parameters:
top (int)
left (int)
bottom (int)
right (int)
- property shape: tuple[int, int]¶
Height and width of rectangle.
- property offset: tuple[int, int]¶
Top-left position of rectangle.
- class psdtags.PsdReferencePoint(x, y)¶
Bases:
PsdKeyABCReference point.
- Parameters:
x (float)
y (float)
- classmethod read(fh, psdformat, key, /, length)¶
Return instance from open file.
- Parameters:
- Return type:
- write(fh, psdformat, /)¶
Write reference point to open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
- Return type:
int
- classmethod frombytes(data, psdformat, key, /)¶
Return instance from bytes.
- class psdtags.PsdResourceBlockABC¶
Bases:
objectAbstract base class for image resource block data.
- abstractmethod classmethod read(fh, psdformat, resourceid, /, name, length)¶
Return instance from open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
resourceid (PsdResourceId)
name (str)
length (int)
- Return type:
- classmethod frombytes(data, psdformat, resourceid, /, name)¶
Return instance from bytes.
- Parameters:
data (bytes)
psdformat (PsdFormat)
resourceid (PsdResourceId)
name (str)
- Return type:
- class psdtags.PsdResourceId(*values)¶
Bases:
IntEnumImage resource IDs.
- class psdtags.PsdSectionDividerSetting(kind, blendmode=None, subtype=None)¶
Bases:
PsdKeyABCSection divider setting (Photoshop 6.0).
- Parameters:
kind (PsdSectionDividerType)
blendmode (PsdBlendMode | None)
subtype (int | None)
- classmethod read(fh, psdformat, key, /, length)¶
Return instance from open file.
- Parameters:
- Return type:
- write(fh, psdformat, /)¶
Write section divider setting to open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
- Return type:
int
- classmethod frombytes(data, psdformat, key, /)¶
Return instance from bytes.
- class psdtags.PsdSectionDividerType(*values)¶
Bases:
IntEnumSection divider setting types.
- class psdtags.PsdSheetColorSetting(color)¶
Bases:
PsdKeyABCSheet color setting (Photoshop 6.0).
- Parameters:
color (PsdColorType)
- classmethod read(fh, psdformat, key, /, length)¶
Return instance from open file.
- Parameters:
- Return type:
- write(fh, psdformat, /)¶
Write color setting to open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
- Return type:
int
- classmethod frombytes(data, psdformat, key, /)¶
Return instance from bytes.
- class psdtags.PsdString(key, value)¶
Bases:
PsdKeyABCUnicode string.
- Parameters:
key (PsdKey)
value (str)
- classmethod read(fh, psdformat, key, /, length)¶
Return instance from open file.
- write(fh, psdformat, /)¶
Write unicode string to open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
- Return type:
int
- classmethod frombytes(data, psdformat, key, /)¶
Return instance from bytes.
- class psdtags.PsdStringBlock(resourceid, value, name='')¶
Bases:
PsdResourceBlockABCUnicode string.
- Parameters:
resourceid (PsdResourceId)
value (str)
name (str)
- classmethod read(fh, psdformat, resourceid, /, name, length)¶
Return instance from open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
resourceid (PsdResourceId)
name (str)
length (int)
- Return type:
- write(fh, psdformat, /)¶
Write Pascal string to open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
- Return type:
int
- classmethod frombytes(data, psdformat, resourceid, /, name)¶
Return instance from bytes.
- Parameters:
data (bytes)
psdformat (PsdFormat)
resourceid (PsdResourceId)
name (str)
- Return type:
- class psdtags.PsdStringsBlock(resourceid, values, name='')¶
Bases:
PsdResourceBlockABCSeries of Unicode strings.
- Parameters:
resourceid (PsdResourceId)
values (list[str])
name (str)
- classmethod read(fh, psdformat, resourceid, /, name, length)¶
Return instance from open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
resourceid (PsdResourceId)
name (str)
length (int)
- Return type:
- write(fh, psdformat, /)¶
Write sequence of Unicode strings to open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
- Return type:
int
- classmethod frombytes(data, psdformat, resourceid, /, name)¶
Return instance from bytes.
- Parameters:
data (bytes)
psdformat (PsdFormat)
resourceid (PsdResourceId)
name (str)
- Return type:
- class psdtags.PsdTextEngineData(data)¶
Bases:
PsdKeyABCText Engine Data (Photoshop CS3).
- Parameters:
data (bytes)
- classmethod read(fh, psdformat, key, /, length)¶
Return instance from open file.
- Parameters:
- Return type:
- write(fh, psdformat, /)¶
Write unicode string to open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
- Return type:
int
- classmethod frombytes(data, psdformat, key, /)¶
Return instance from bytes.
- class psdtags.PsdThumbnailBlock(resourceid, format, width, height, rawdata, name='')¶
Bases:
PsdResourceBlockABCThumbnail 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:
fh (BinaryIO)
psdformat (PsdFormat)
resourceid (PsdResourceId)
name (str)
length (int)
- Return type:
- write(fh, psdformat, /)¶
Write Thumbnail resource format to open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
- 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.
- classmethod frombytes(data, psdformat, resourceid, /, name)¶
Return instance from bytes.
- Parameters:
data (bytes)
psdformat (PsdFormat)
resourceid (PsdResourceId)
name (str)
- Return type:
- class psdtags.PsdUnicodeString(value)¶
Bases:
objectUnicode string.
- Parameters:
value (str)
- class psdtags.PsdUnknown(key, psdformat, value)¶
Bases:
PsdKeyABCUnknown keys stored as opaque bytes.
- classmethod frombytes(data, psdformat, key, /)¶
Return instance from bytes.
- Parameters:
- Return type:
- classmethod read(fh, psdformat, key, /, length)¶
Return instance from open file.
- Parameters:
- Return type:
- class psdtags.PsdUserMask(colorspace=PsdColorSpaceType.UNKNOWN, components=(0, 0, 0, 0), opacity=0, flag=128)¶
Bases:
PsdKeyABCUser 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:
- tobytes(psdformat, /)¶
Return user mask record.
- Parameters:
psdformat (PsdFormat)
- Return type:
bytes
- class psdtags.PsdVersionBlock(resourceid, version, file_version, writer_name, reader_name, has_real_merged_data, name='')¶
Bases:
PsdResourceBlockABCImage 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:
fh (BinaryIO)
psdformat (PsdFormat)
resourceid (PsdResourceId)
name (str)
length (int)
- Return type:
- write(fh, psdformat, /)¶
Write instance values to open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
- Return type:
int
- classmethod frombytes(data, psdformat, resourceid, /, name)¶
Return instance from bytes.
- Parameters:
data (bytes)
psdformat (PsdFormat)
resourceid (PsdResourceId)
name (str)
- Return type:
- class psdtags.PsdVirtualMemoryArray(iswritten=False, depth=None, rectangle=None, pixeldepth=None, compression=PsdCompressionType.RAW, data=None)¶
Bases:
objectVirtual 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:
fh (BinaryIO)
psdformat (PsdFormat)
- Return type:
- write(fh, psdformat, /)¶
Write virtual memory array to open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
- 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.
- class psdtags.PsdVirtualMemoryArrayList(rectangle, channels=<factory>)¶
Bases:
objectVirtual memory array list.
- Parameters:
rectangle (PsdRectangle)
channels (list[PsdVirtualMemoryArray])
- class psdtags.PsdWord(key, value)¶
Bases:
PsdKeyABCFour bytes.
- Parameters:
key (PsdKey)
value (bytes)
- classmethod read(fh, psdformat, key, /, length)¶
Return instance from open file.
- write(fh, psdformat, /)¶
Write four bytes value to open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
- Return type:
int
- classmethod frombytes(data, psdformat, key, /)¶
Return instance from bytes.
- class psdtags.TiffImageResources(psdformat, blocks, name=None)¶
Bases:
objectTIFF ImageResources tag #34377.
- Parameters:
psdformat (PsdFormat)
blocks (list[PsdResourceBlockABC])
name (str | None)
- classmethod read(fh, length, name=None)¶
Return instance from open file.
- Parameters:
fh (BinaryIO)
length (int)
name (str | None)
- Return type:
- classmethod frombytes(data, name=None)¶
Return instance from ImageResources tag value.
- Parameters:
data (bytes)
name (str | None)
- Return type:
- classmethod fromtiff(filename, /, pageindex=0)¶
Return instance from ImageResources tag in TIFF file.
- Parameters:
filename (os.PathLike[Any] | str)
pageindex (int)
- Return type:
- 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.
- class psdtags.TiffImageSourceData(psdformat, layers, usermask, info=<factory>, name=None)¶
Bases:
objectTIFF ImageSourceData tag #37724.
- Parameters:
psdformat (PsdFormat)
layers (PsdLayers)
usermask (PsdUserMask)
info (list[PsdKeyABC])
name (str | None)
- classmethod read(fh, /, name=None, *, unknown=True)¶
Return instance from open file.
- Parameters:
fh (BinaryIO)
name (str | None)
unknown (bool)
- Return type:
- classmethod frombytes(data, /, *, name=None, unknown=True)¶
Return instance from bytes.
- Parameters:
data (bytes)
name (str | None)
unknown (bool)
- Return type:
- classmethod fromtiff(filename, /, *, pageindex=0, unknown=True)¶
Return instance from TIFF file.
- Parameters:
filename (os.PathLike[Any] | str)
pageindex (int)
unknown (bool)
- Return type:
- write(fh, /, psdformat=None, *, compression=None, unknown=True, maxworkers=1)¶
Write ImageResourceData tag value to open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat | bytes | None)
compression (PsdCompressionType | None)
unknown (bool)
maxworkers (int)
- Return type:
int
- tobytes(psdformat=None, *, compression=None, unknown=True, maxworkers=1)¶
Return ImageResourceData tag value as bytes.
- Parameters:
psdformat (PsdFormat | bytes | None)
compression (PsdCompressionType | None)
unknown (bool)
maxworkers (int)
- Return type:
bytes
- tifftag(psdformat=None, compression=None, *, unknown=True, maxworkers=1)¶
Return tifffile.TiffWriter.write extratags item.
- Parameters:
psdformat (PsdFormat | bytes | None)
compression (PsdCompressionType | None)
unknown (bool)
maxworkers (int)
- 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.
- psdtags.compress(data, compression, rlecountfmt)¶
Return compressed big-endian numpy array.
- Parameters:
data (NDArray[Any])
compression (PsdCompressionType)
rlecountfmt (str)
- 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.
- 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:
fh (BinaryIO)
blocks (PsdResourceBlockABC)
- Return type:
int
- psdtags.write_psdtags(fh, psdformat, /, compression, maxworkers, align, *, unknown=True, tags)¶
Write sequence of tags to open file.
- Parameters:
fh (BinaryIO)
psdformat (PsdFormat)
compression (PsdCompressionType | None)
maxworkers (int)
align (int)
unknown (bool)
- Return type:
int
- psdtags.REPR_MAXLEN¶
Maximum length of bytes to show in repr().