psd_tools.psd.image_data

Image data section structure.

ImageData corresponds to the last section of the PSD/PSB file where a composited image is stored. When the file does not contain layers, this is the only place pixels are saved.

ImageData

class psd_tools.psd.image_data.ImageData(compression=<Compression.RAW: 0>, data: bytes = b'')[source]

Merged channel image data.

compression

See Compression.

data

bytes as compressed in the compression flag.

get_data(header)[source]

Get decompressed data.

Parameters:header – See FileHeader.
Returns:list of bytes corresponding each channel.
classmethod new(header, color=0, compression=<Compression.RAW: 0>)[source]

Create a new image data object.

Parameters:
  • header – FileHeader.
  • compression – compression type.
  • color – default color. int or iterable for channel length.
set_data(data, header)[source]

Set raw data and compress.

Parameters:
  • data – list of raw data bytes corresponding channels.
  • compression – compression type, see Compression.
  • header – See FileHeader.
Returns:

length of compressed data.