psd-tools is a Python package for working with Adobe Photoshop PSD files
as described in specification.
- Read and write of the low-level PSD/PSB file structure
- Raw layer image export in NumPy and PIL format
- Composition of basic pixel-based layers
- Composition of fill layer effects
- Vector masks
- Editing of some layer attributes such as layer name
- Blending modes except for dissolve
- Drawing of bezier curves
- Editing of layer structure, such as adding or removing a layer
- Composition of adjustment layers
- Composition of many layer effects
- Font rendering
Use pip to install the package:
pip install psd-tools
from psd_tools import PSDImage
psd = PSDImage.open('example.psd')
for layer in psd:
layer_image = layer.composite()
layer_image.save('%s.png' % layer.name)
Check out the documentation for features and details.
See contributing page.
PSD specification is far from complete. If you cannot find a desired
information in the documentation, you should inspect the low-level
- [api] Fix incorrect has_effects behavior (#322)
- [composite] Improve blending numerical stability (#321)
- [composite] Improve non-RGB modes and transparency (#319, @Etienne-Gautier)
- [psd] Workaround assertion error in broken file (#320)
- [ci] Update CI configuration (#313 #314)
- [composite] Fix composite errors (#312)
- [psd] Suppress vowv tagged blocks (#306)
- [composite] Fix rasterized shape composite (#301 #302)
- [api] Fix missing effect attributes (#284)
- [package] Support additional platforms (i686, aarch64, universal2, win32)
- [package] Drop py36 support
- [api] Fix incorrect fill layer parse (fix #254)
- [package] Drop py27 and py35 support
- [psd] Workaround Enum bug (fix #241)
- [composite] Fix transparency issue (fix #242)
- [composite] Fix mask disable flag (fix #243)
- [api] Add workaround for creating PSB (fix #246)
- [api] Fix incorrect adjustment parse (fix #247)
- [composite] Fix ignored clip layers for groups.
- [composite] Fix out-of-viewport stroke effect.
- [api] Bugfix for PSDImage composite layer_filter option.
- [api] Bugfix for transparency and alpha distinction.
- [psd] Rename COMPOSITOR_INFO.
- [composite] Fix stroke effect target shape.
- [api] Bugfix for PSDImage init internal.
- [psd] Bugfix for CurvesExtraMarker read.
- [composite] Fix layer check.
- [psd] Fix engine data parser.
- [composite] Fix stroke effect argument.
- [composite] Fix incorrect fill opacity handling in compositing.
- [composite] Fix incorrect alpha for patterns.
- [composite] Fix path operation for merged components.
- [composite] Fix vector mask compositing condition.
- [composite] Fix incorrect alpha channel handling in composite.
- [api] Add ignore_preview option to PSDImage.composite.
- [composite] Improve stroke effect composition for vector masks.
- [composite] Avoid crash when there is an erroneous subpath.
- [composite] Workaround possible divide-by-zero warn in stroke composition.
- [composite] Fix incorrect pattern transparency handling.
- [composite] Fix ignored effects in direct group composition.
- [composite] Fix incorrect opacity handling for clip layers.
- [compression] Security fix, affected versions are 1.8.37 - 1.9.3.
- [composite] Fix memory corruption crash for pattern data in PSB files.
- [psd] Add image data pretty printing.
- [psd] Add missing resource ID.
- [psd] Fix pretty printing regression.
- [psd] Fix big tag key for linked layers.
- [psd] Support frgb tag.
- [psd] Support sgrp metadata key.
- [psd] Support patt tag.
- [psd] Workaround unknown engine data.
- [composite] Implement NumPy-based compositing functionality.
- [composite] Support blending modes other than dissolve.
- [composite] Support blending in RGB, CMYK, Grayscale.
- [api] Introduce NumPy array export method.
- [api] Drop deprecated methods from v1.7.x such as as_PIL.
- [api] Deprecate compose method.
- [compression] Rename packbits to rle.
- [compression] Improve RLE decode efficiency.
- [tests] Additional compositing tests.
- [composer] fix crash when gradient fill is in stroke.
- [compression] Remove packbits dependency and introduce cython implementation.
- [deploy] Move CI provider from Travis-CI to Github Actions.
- [deploy] Start distributing binary wheels.
- [psd] add safeguard for malformed global layer mask info parser.
- [api] remove duplicate has_mask() definition.
- [composer] fix empty effects check.
- [api] fix compose() arguments.
- [psd] fix attrs version dependency.
- [api] add include_invisible option to Group.extract_bbox.
- [psd] fix deprecated attrs api.
- [psd] fix 16/32 bit file parsing bug introduced in 1.8.17.
- [psd] bugfix reading psb.
- [psd] bugfix reading slices resource.
- [security] update dependency to pillow >= 6.2.0.
- [psd] workaround for reading less-than-4-byte int in malformed psd files.
- [composer] fix vector mask bbox in composition.
- [api] fix Effects.__repr__() when data is empty.
- [api] accept encoding param in PSDImage.open and PSDImage.save.
- [deploy] bugfix travis deployment condition.
- [composer] support group mask.
- [api] change return type of PSDImage.color_mode to enum.
- [api] support reading of bitmap color mode.
- [api] support channel option in topil() method.
- [composer] experimental support of commutative blending modes.
- [composer] fix clipping on alpha-less image;
- [composer] fix stroke effect for flat plane;
- [composer] workaround for insufficient knots;
- [composer] fix for custom color space.
- fix pass-through composing bug;
- fix alpha blending in effect;
- fix vector mask composition;
- experimental support for shape stroke;
- experimental support for stroke effect.
- change effect property return type from str to enum;
- improve gradient quality;
- support fill opacity and layer opacity;
- add tmln key in metadata setting.
- fix broken psd_tools.composer.vector module in 1.8.17;
- experimental support for color noise gradient;
- bugfix for clip masks;
- bugfix for CMYK composing.
- move psd_tools.api.composer module to psd_tools.composer package;
- support 19 blending modes in composer;
- support fill opacity;
- fix image size when composing with masks;
- rename TaggedBlockID to Tag;
- rename ImageResourceID to Resource;
- add bytes mixin to Enum constants;
- replace Enum keys with raw values in psd_tools.psd.base.Dict classes.
- fix broken group compose in 1.8.15;
- fix missing pattern / gradient composition in vector stroke content.
- coding style fix;
- fix compose() bbox option.
- add dependency to aggdraw;
- support bezier curves in vector masks;
- support path operations;
- fix compose(force=True) behavior;
- fix default background color in composer;
- improve pattern overlay parameters support;
- fix gradient map generation for a single stop.
- fix engine_data unknown tag format;
- fix compose for extra alpha channels;
- workaround for pillow 6.0.0 bug.
- add apply_icc option in pil io.
- introduce terminology module;
- reduce memory use in read;
- add main testing.
- fix PSB extn key size bug.
- documentation updates;
- introduce Artboard class.
- revert package name to psd_tools;
- prepare merging to the main repo.
- change _psd pointer in PSDImage;
- add version property;
- support fill effects in composer.
- change tagged block/image resource singleton accessor in user API;
- add documentation on iterator order;
- fix export setting 1 big key config;
- fix computer info big key config.
- add channel size checking in topil;
- add mlst metadata decoding;
- fix key collision issue in descriptor;
- performance improvement for packbit encoding/decoding;
- drop cython dependency in travis config;
- implement thumbnail, is_group, and parent methods in PSDImage.
- major API changes;
- package name changed to psd_tools2;
- completely rewritten decoding subpackage psd_tools2.psd;
- improved composer functionality;
- file write support;
- drop cython compression module and makes the package pure-python;
- drop pymaging support.
- composer alpha blending fix;
- documentation fix.
- support cinf tagged block.
- add missing extra image resource block signatures.
- move psd_tools tests under tests/psd_tools.
- fix alpha channel visibility of composed image.
- fix unit rectangle drawing size.
- fix ignored visibility in bbox calculation.
- drop py34 support;
- fix tobytes deprecation warning.
- fix gradient descriptor bug.
- fix coloroverlay bug;
- fix gradient angle bug;
- fix curves decoder bug.
- add shape rendering in compose();
- add grayscale support.
- fix has_pixel() condition.
- fix fill opacity in compose();
- workaround for broken PrintFlags.
- fix color overlay issue in compose().
- fix verbose arg for python 3.7 compatibility.
- fix has_pixel() for partial channels;
- support color overlay in compose().
- fix mask rendering in compose (Thanks @andrey-hider and @nkato).
- fix descriptor decoding errors;
- minor bugfixes.
- fix UnicodeError in exif;
- workaround for irregular descriptor name;
- add undocumented extn tagged block decoding;
- move duplicated icc module to subpackage;
- support PIL rendering with extra alpha channels.
- update documentation;
- fix PEP8 compliance;
- rename merge_layers to compose.
- fix white background issue in as_PIL().
- add quality testing;
- fix disabled mask.
- fix has_mask() condition;
- add mask composition in merge_layers();
- fix mask display.
- fix infinity loop in print_tree().
- add vector origination API;
- fix shape and vector mask identification;
- change enum name conversion;
- update docs.
- add adjustments API;
- add mask API;
- bugfix for tagged_blocks decoders.
- add mask user API;
- add layer coordinate user API;
- add vector mask and vector stroke API;
- cleanup user API;
- add automatic descriptor conversion.
- cleanup user API organization;
- remove json encoder api;
- make cli a package main.
- workaround for anaconda 2.7 pillow;
- bbox existence checkf.
- experimental clipping support in merge_layer();
- revert as_PIL() in AdjustmentLayer.
- Small fix for erroneous unicode path name
- Add all_layers() method;
- Add _image_resource_blocks property;
- Add thumbnail() method.
- documentation updates;
- github repository renamed to psd-tools2;
- AdjustmentLayer fix.
- layer class structure reorganization;
- add Effects API;
- add TypeLayer API methods.
- PSDImage user API update;
- user API adds distinct layer types;
- Sphinx documentation.
- implemented many decodings of image resources and tagged blocks;
- implemented EngineData text information;
- user API for getting mask and patterns;
- user API to calculate bbox for shape layers;
- Fixed reading of layer mask data (thanks Evgeny Kopylov);
- Python 2.6 support is dropped;
- Python 3.6 support is added (thanks Leendert Brouwer);
- extension is rebuilt with Cython 0.25.2.
- fixed references decoding (thanks Josh Drake);
- fixed PIL support for CMYK files (thanks Michael Wu);
- optional C extension is rebuilt with Cython 0.23.4;
- Python 3.2 support is dropped; the package still works in Python 3.2,
but the compatibility is no longer checked by tests, and so it can break
- declare Python 3.5 as supported.
- implemented extraction of embedded files (embedded smart objects) -
thanks Volker Braun;
- optional C extension is rebuilt with Cython 0.21.2.
- hg mirror on bitbucket is dropped, sorry!
- improved METADATA_SETTING decoding (thanks Evgeny Kopylov);
- layer comps decoding (thanks Evgeny Kopylov);
- improved smart objects decoding (thanks Joey Gentry);
- user API for getting layer transforms and placed layer size
(thanks Joey Gentry);
- IPython import is deferred to speedup psd-tools.py command-line utility;
- _RootGroup.__repr__ is fixed;
- warning message building is more robust;
- optional C extension is rebuilt with Cython 0.21.1.
- Fixed reading of images with layer masks (thanks Evgeny Kopylov);
- improved mask data decoding (thanks Evgeny Kopylov);
- fixed synchronization in case of 8B64 signatures (thanks Evgeny Kopylov);
- fixed reading of layers with zero length (thanks Evgeny Kopylov);
- fixed Descriptor parsing (thanks Evgeny Kopylov);
- some of the descriptor structures and tagged block constants are renamed (thanks Evgeny Kopylov);
- PATH_SELECTION_STATE decoding (thanks Evgeny Kopylov);
- the library is switched to setuptools; docopt is now installed automatically.
- Layer effects parsing (thanks Evgeny Kopylov);
- trailing null bytes are stripped from descriptor strings
(thanks Evgeny Kopylov);
- “Reference” and “List” descriptor parsing is fixed
(thanks Evgeny Kopylov);
- scalar descriptor values (doubles, floats, booleans) are now returned
as scalars, not as lists of size 1 (thanks Evgeny Kopylov);
- fixed reading of EngineData past declared length
(thanks Carlton P. Taylor);
- “background color” Image Resource parsing (thanks Evgeny Kopylov);
- psd_tools.decoder.actions.Enum.enum field is renamed to
psd_tools.decoder.actions.Enum.value (thanks Evgeny Kopylov);
- code simplification - constants are now bytestrings as they should be
(thanks Evgeny Kopylov);
- Python 3.4 is supported.
- Improved merging of transparent layers (thanks Vladimir Timofeev);
- fixed layer merging and bounding box calculations for empty layers
(thanks Vladimir Timofeev);
- C extension is rebuilt with Cython 0.20.1.
- psd-tools.py command-line interface is changed, ‘debug’ command is added;
- pretty-printing of internal structures;
- pymaging support is fixed;
- allow ‘MeSa’ to be a signature for image resource blocks
(thanks Alexey Buzanov);
- psd_tools.debug.debug_view utility function is fixed;
- Photoshop CC constants are added;
- Photoshop CC vector origination data is decoded;
- binary data is preserved if descriptor parsing fails;
- more verbose logging for PSD reader;
- channel data reader became more robust - now it doesn’t read past
declared channel length;
- psd-tools.py –version command is fixed;
- lsdk tagged blocks parsing: this fixes some issues with layer grouping
(thanks Ivan Maradzhyiski for the bug report and the patch);
- CMYK images support is added (thanks Alexey Buzanov, Guillermo Rauch and
https://github.com/a-e-m for the help);
- Grayscale images support is added (thanks https://github.com/a-e-m);
- LittleCMS is now optional (but it is still required to get proper colors).
- Point and Millimeter types are added to UnitFloatType (thanks Doug Ellwanger).
- Some issues with descriptor parsing are fixed (thanks Luke Petre).
- Python 2.x: reading data from file-like objects is fixed
(thanks Pavel Zinovkin).
- Fixed parsing of layer groups without explicit OPEN_FOLDER mark;
- Cython extension is rebuilt with Cython 0.18.
- Descriptor parsing (thanks Oliver Zheng);
- text (as string) is extracted from text layers (thanks Oliver Zheng);
- improved support for optional building of Cython extension.
- Typo is fixed: LayerRecord.cilpping should be LayerRecord.clipping.
Thanks Oliver Zheng.
- Highly experimental: basic layer merging is implemented
(e.g. it is now possible to export layer group to a PIL image);
- Layer.visible no longer takes group visibility in account;
- Layer.visible_global is the old Layer.visible;
- psd_tools.user_api.combined_bbox made public;
- Layer.width and Layer.height are removed (use layer.bbox.width
and layer.bbox.height instead);
- pil_support.composite_image_to_PIL is renamed to pil_support.extract_composite_image and
pil_support.layer_to_PIL is renamed to pil_support.extract_layer_image
in order to have the same API for pil_support and pymaging_support.
- psd.composite_image() is renamed to psd.as_PIL();
- Pymaging support: psd.as_pymaging() and layer.as_pymaging() methods.
- Support for zip and zip-with-prediction compression methods is added;
- support for 16/32bit layers is added;
- optional Cython extension for faster zip-with-prediction decompression;
- other speed improvements.
- Initial support for 16bit and 32bit PSD files: psd-tools v0.2 can
read composite (merged) images for such files and extract information
(names, dimensions, hierarchy, etc.) about layers and groups of 16/32bit PSD;
extracting image data for distinct layers in 16/32bit PSD files is not
- better Layer.__repr__;
- bbox property for Group.
Packaging is fixed in this release.
- Better support for 32bit images (still incomplete);
- reader is able to handle “global” tagged layer info blocks that
was previously discarded.
- warn about 32bit images;
- transparency support for composite images.
Initial release (v0.1 had packaging issues).