psd_tools.psd.image_data

Image data section structure.

ImageData

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

Merged channel image data.

compression

See Compression.

data
compression
data
get_data(header)[source]

Get decompressed data.

Parameters:header – See FileHeader.
Returns:list of bytes corresponding each channel.
Return type:list
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.
classmethod read(fp)[source]

Read the element from a file-like object.

Parameters:fp – file-like object
Return type:ImageData
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.

write(fp)[source]

Write the element to a file-like object.

Parameters:fp – file-like object
Return type:int