pytoshop.color_mode

The ColorModeData section.

class pytoshop.color_mode.ColorModeData(data=b'')[source]

Bases: object

Color mode data section.

Only indexed color and duotone (see core.Header.color_mode) have color mode data.

Indexed color images: length is 768; color data contains the color table for the image, in non-interleaved order.

Duotone images: color data contains the duotone specification (the format of which is not documented). Other applications that read Photoshop files can treat a duotone image as a gray image, and just preserve the contents of the duotone information when reading and writing the file.

Note that pytoshop doesn’t do anything meaningful for color mode data, and only stores the raw bytes in order to round-trip.

data
length(header)[source]

The length of the section, in bytes, not including its header.

classmethod read(fd, header)[source]

Instantiate from a file-like object.

Parameters:
  • fd (file-like object) – Must be readable, seekable and open in binary mode.
  • header (PsdFile object) – An object to get global file information from.
write(fd, header)[source]

Write to a file-like object.

Parameters:
  • fd (file-like object) – Must be writable, seekable and open in binary mode.
  • header (PsdFile object) – An object to get global file information from.