Photoshop Document

The .PSD (Photoshop Document) format stores an image with support for most imaging options available in Adobe Photoshop program. These include layers with masks, color spaces, ICC profiles, transparency, text, alpha channels, etc.

Loading and saving of indexed, grayscale, RGB(A), HDR (FP32), and CMYK (auto converted to RGB) images is supported. Non-HDR gray, RGB, and CMYK images can have 8bit or 16bit color channels. There is no support for loading mono images, duotone images are treated like grayscale images, and multichannel and CIE Lab images are loaded as RGB images but without actual conversion to RGB color space. Also no layer information is loaded.

As of Imaging version 0.26.2 images with alpha channel can be saved using layers. That way when opened in Photoshop they have proper transparency, not alpha channel (will have one layer, RGB color channels, and transparency). PSD files with layers are bigger because image has to be stored as background as well as layer data. Therefore, RLE compression was implemented to keep the files smaller (Photoshop saves PSDs RLE compressed too by default). Note that layers are not supported for floating point image data formats since it's not supported by Photoshop itself. Saving of layers can also be disabled (will be opened in PS as background raster with RGBA channels) using appropriate option.

Photoshop Document File Format Support
FormatTImageFormat equivalentLoadingSaving
8 bit indexed ifIndex8 YesYes
24 bit RGB ifR8G8B8 YesYes
48 bit RGB ifR16G16B16 YesYes
32 bit ARGB ifA8R8G8B8 YesYes
64 bit ARGB ifA16R16G16B16 YesYes
8 bit grayscale ifGray8 YesYes
16 bit grayscale ifGray16 YesYes
16 bit grayscale + alpha ifA8Gray8 YesYes
32 bit grayscale + alpha ifA16Gray16 YesYes
32 bit R FP32 ifR32F YesYes
128 bit ARGB FP32 ifA32B32G32R32F YesYes
other types depends on type Yes/NoNo

When working with PSD files you can find useful some options which can be set by SetOption function and their current values can be get by GetOption function. Or you can set them by modifying properties of TPSDFileFormat class.

Options Related to PSD Files
OptionIdAllowed ValuesUsage
ImagingPSDSaveAsLayer 0 (false) or 1 (true)If enabled image data is saved as layer of PSD file. This is required to get proper transparency when opened in Photoshop for images with alpha data (will be opened with one layer, RGB color channels, and transparency). If you don't need this Photoshop compatibility turn this option off as you'll get smaller file (will be opened in PS as background raster with RGBA channels) Default value is 1 (true).