PhotoshopFile#

Class Reference PhotoshopFile#

class psapi.PhotoshopFile#

This class represents the low-level File Structure of the Photoshop document itself. In the python bindings we explicitly do not expose all of its sub-classes as the implementation details are currently not meant to be accessed

static find_bitdepth(path: os.PathLike) psapi.enum.BitDepth#

Find the bit depth of a Photoshop file from the given filepath.

This function has basically no runtime cost as it simply reads the first 26 bytes of the document and uses that to extract the bit depth. The intention of this function is to provide an interface to quickly check which psapi.LayeredFile instance to construct. For example

depth = psapi.PhotoshopFile.find_bitdepth("SomeFile.psb")
if (depth == psapi.enum.BitDepth.bd_8):
    layered_file = psapi.LayeredFile_8bit.read("SomeFile.psb")
# etc...
Parameters:

filepath (str) – The path to the Photoshop file.

Returns:

The bit depth of the Photoshop file as an Enum::BitDepth.

Return type:

psapi.enum.BitDepth

read(self: psapi.PhotoshopFile, document: psapi.util.File) None#

Read the PhotoshopFile class from a File instance, this file must be a valid .psd or .psb file.

Parameters:

document (psapi.util.File) – The file object used for reading

Return type:

None

write(self: psapi.PhotoshopFile, document: psapi.util.File) None#

Write the PhotoshopFile class to disk using a instance, this file must be a valid .psd or .psb file.

Parameters:

document (psapi.util.File) – The file object used for writing

Return type:

None