psd_tools.psd

Low-level API that translates binary data to Python structure

PSD

class psd_tools.psd.PSD(header=NOTHING, color_mode_data=NOTHING, image_resources=NOTHING, layer_and_mask_information=NOTHING, image_data=NOTHING)[source]

Low-level PSD file structure that resembles the specification.

Example:

from psd_tools.psd import PSD

with open(input_file, 'rb') as f:
    psd = PSD.read(f)

with open(output_file, 'wb') as f:
    psd.write(f)
header

See FileHeader.

color_mode_data

See ColorModeData.

image_resources

See ImageResources.

layer_and_mask_information

See LayerAndMaskInformation.

image_data

See ImageData.

color_mode_data
classmethod frombytes(data, *args, **kwargs)

Read the element from bytes.

Parameters:data – bytes
header
image_data
image_resources
layer_and_mask_information
classmethod read(fp, encoding='macroman', **kwargs)[source]

Read the element from a file-like object.

Parameters:fp – file-like object
Return type:PSD
tobytes(*args, **kwargs)

Write the element to bytes.

Return type:bytes
validate()

Validate the attribute.

write(fp, encoding='macroman', **kwargs)[source]

Write the element to a file-like object.