pytoshop.core

The core objects, including the PsdFile and its Header.

class pytoshop.core.Header(version=<Version.version_1: 1>, num_channels=1, height=1, width=1, depth=<ColorDepth.depth8: 8>, color_mode=<ColorMode.rgb: 3>)[source]

Bases: object

Manages the header at the start of a PSD/PSB file.

color_mode

Color mode of the file. See enums.ColorMode.

depth

Number of bits per channel. See enums.ColorDepth.

classmethod header_read(fd)[source]

Instantiate from a file-like object.

Parameters:fd (file-like object) – Must be readable, seekable and open in binary mode.
height

Height of the image (in pixels).

max_size_mapping = {1: 30000, 2: 300000}
num_channels

Number of color channels in the file.

shape
version

The version of the file format. See enums.Version.

width

Width of the image (in pixels).

write(fd)[source]

Write to a file-like object.

Parameters:fd (file-like object) – Must be writable, seekable and open in binary mode.
class pytoshop.core.PsdFile(version=<Version.version_1: 1>, num_channels=1, height=1, width=1, depth=<ColorDepth.depth8: 8>, color_mode=<ColorMode.rgb: 3>, color_mode_data=None, image_resources=None, layer_and_mask_info=None, image_data=None, compression=<Compression.raw: 0>)[source]

Bases: pytoshop.core.Header

Represents an entire PSD file.

color_mode_data

Color mode data section. See color_mode.ColorModeData.

image_data

Image data. See image_data.ImageData.

image_resources

Image resources. See image_resources.ImageResources.

layer_and_mask_info

Image resources. See image_resources.ImageResources.

classmethod read(fd)[source]

Instantiate from a file-like object.

Parameters:fd (file-like object) – Must be readable, seekable and open in binary mode.
write(fd)[source]

Write to a file-like object.

Parameters:fd (file-like object) – Must be writable, seekable and open in binary mode.