psd_tools.psd.header

File header structure.

FileHeader

class psd_tools.psd.header.FileHeader(signature: bytes = b'8BPS', version: int = 1, channels: int = 4, height: int = 64, width: int = 64, depth: int = 8, color_mode=<ColorMode.RGB: 3>)[source]

Header section of the PSD file.

Example:

from psd_tools.psd.header import FileHeader
from psd_tools.constants import ColorMode

header = FileHeader(channels=2, height=359, width=400, depth=8,
                    color_mode=ColorMode.GRAYSCALE)
signature

Signature: always equal to b'8BPS'.

version

Version number. PSD is 1, and PSB is 2.

channels

The number of channels in the image, including any alpha channels.

height

The height of the image in pixels.

width

The width of the image in pixels.

depth

The number of bits per channel.

color_mode

The color mode of the file. See ColorMode

channels
color_mode
depth
height
classmethod read(fp)[source]

Read the element from a file-like object.

Parameters:fp – file-like object
Return type:FileHeader
signature
version
width
write(fp)[source]

Write the element to a file-like object.

Parameters:fp – file-like object