A modern and performant C++20 read/write parser of Photoshop Files (*.psd and *.psb) with fully fledged Python bindings hosted on PyPi
A modern and performant C++20 read/write parser of Photoshop Files (*.psd and *.psb) with fully fledged Python bindings hosted on PyPi
)
[!NOTE] The PhotoshopAPI is still in early development status which means it is subject to change and will likely include bugs. If you find any please report them to the issues page
PhotoshopAPI is a C++20 Library with Python bindings for reading and writing of Photoshop Files (*.psd and *.psb) based on previous works from psd_sdk, pytoshop and psd-tools. As well as the official Photoshop File Format Specification, where applicable. The library is continuously tested for correctness in its core functionality. If you do find a bug please submit an issue to the github page.
The motivation to create another library despite all the other works present is that there isn't a library which has layer editing as a first class citizen while also supporting
all bit-depths known to Photoshop (8-bits, 16-bits, 32-bits). This Library aims to create an abstraction between the raw binary file format and the structure that the user interfaces
against to provide a more intuitive approach to the editing of Photoshop Files.
Photoshop itself is unfortunately often slow to read/write files and the built-in tools for automatically/programmatically modifying files suffer this same issue. On top of this, due to the extensive history of the Photoshop File Format, Photoshop files written out by Photoshop itself are often unnecessarily bloated to add backwards compatibility or cross-software compatibility.
The PhotoshopAPI tries to address these issue by allowing the user to read/write/modify Photoshop Files without ever having to enter Photoshop itself which additionally means, no license is required. It is roughly 5-10x faster in reads and 20x faster in writes than photoshop while producing files that are consistently 20-50% lower in size (see the benchmarks section on readthedocs for details). The cost of parsing is paid up front either on read or on write so modifying the layer structure itself is almost instantaneous (except for adding new layers).
Supported:
Planned:
Not Supported:
The PhotoshopAPI comes with Python bindings which can be installed using
$ py -m pip install PhotoshopAPIalternatively the wheels can be downloaded from the Releases page. For examples on how to use the python bindings please refer to the Python Bindings section on Readthedocs or check out the PhotoshopExamples/ directory on the github page which includes examples for Python as well as C++.
For an even quicker way of getting started check out the Quickstart section!
The full documentation with benchmarks, build instructions and code reference is hosted on the PhotoshopAPI readthedocs page.
This goes over requirements for usage, for development requirements please visit the docs.
The python bindings support python >=3.7 (except for ARM-based MacOS machines which raise this to >=3.10)
1 Currently Linux is supported only as manylinux build and has some features disabled such as timestamps on logging.
The PhotoshopAPI is built with performance as one of its foremost concerns. Using it should enable you to optimize your pipeline rather than slow it down. It runs fully multithreaded with SIMD instructions to leverage all the computing power your computer can afford.
As the feature set increases this will keep being one of the key requirements. For detailed benchmarks please visit the docs
The primary struct to familiarize yourself with when using the PhotoshopAPI is the LayeredFile as well as all its Layer derivatives (such as ImageLayer and
GroupLayer), all of these are template structs for each of the available bit depths.
To get a feel of what is possible with the API as well as how to use it please refer to PhotoshopExample/ directory. To familiarize
yourself with the main concepts, as well as recommended workflows check out the docs or the examples.
If more fine grained control over the binary structure is necessary, one can modify the PhotoshopFile which is what is parsed by the API internally. Do keep in mind that this requires a deep understanding of how the Photoshop File Format works.
Below is a minimal example to get started with opening a PhotoshopFile, removing some layer, and writing the file back out to disk:
…The same code for reading and writing can also be used to for example LayeredFile::move_layer_ or LayeredFile::add_layer as well as extracting any image data
…No open issues yet, or sync has not completed.