Skip to main content

Module psd

Module psd 

Source
Expand description

The merged (composite) image of Photoshop PSD, PSDT and PSB files, read from the public Adobe file format specification: header, colour mode data, image resources (ICC profile, EXIF orientation, version info, indexed transparency), the layer section (skipped, but for whether the merged image has transparency) and the image data, raw or RLE.

Nothing is read into memory whole. The row table gives each row’s place in the file, so any part of the picture is decoded on its own, row by row. Beyond the pixels the caller asks for, memory is at most CHUNK_BYTES of compressed data and a decoded row per channel in use (five at most), and the row table: 8 bytes per row per channel in use, 12 MB for a 300000-row PSB.

Colour goes to 8-bit sRGB:

  • With an embedded ICC profile, RGB, grayscale, CMYK and indexed pixels go through it (moxcms).
  • Without one, RGB and gray are taken as sRGB (32-bit samples as linear sRGB), and CMYK goes through the naive R = (1 - C)(1 - K).
  • Lab is converted from its D50 definition, and duotone shows the gray image the file stores (its ink curves are undocumented). Bitmap is black and white.

Only the first extra channel is alpha, and only when the file says the merged image has transparency: a negative layer count or a Mtrn, Mt16 or Mt32 block in the layer section. Any other extra channel is a saved selection or a spot colour. Photoshop stores such a merged image blended over white; the white is taken back out.

Structs§

Composite
An open merged image. Reading it doesn’t hold the file in memory.

Enums§

PsdError
Why a file’s merged image can’t be shown.

Constants§

CHUNK_BYTES
Compressed bytes read from the file at a time, per channel.

Functions§

dimensions
The image’s size after its orientation, from the merged image when it can be read, else from the header alone.
handles
Whether ext (lowercase, no dot) is a Photoshop document.