Introduction
PSD is the native file format of Adobe Photoshop. It keeps a whole working document: every layer with its blend mode and opacity, masks, adjustment layers, text, paths, guides and colour profiles, as well as a flattened copy of the finished image.
Adobe publishes a specification of the format. Documents larger than 30,000 pixels on a side or 2 GB in size use the Large Document Format, PSB, which has the same layout with wider length fields. Many other editors read PSD, though each supports a different share of Photoshop’s features.
Structure
A PSD file has five sections in a fixed order, and all numbers are big-endian. The
26-byte header starts with 8BPS and gives the version (1 for PSD, 2 for PSB),
the number of channels, the height and width, the bits per channel and the colour mode.
The three sections after it start with their own length, so a reader can skip what it
does not need; the image data runs to the end of the file.
0File header8BPS, version, channels, size, depth, colour mode26 bytes26Colour mode data the palette of an indexed image or the duotone settings, otherwise empty4 bytes and up…Image resources8BIMblocks: resolution, guides, thumbnail, profilevaries…Layer and mask information each layer’s bounds, blend mode, masks and pixel channelsvaries…Image data the flattened composite, raw or compressedvaries
The full layout is in the reference pages: the header, colour mode data and image data, the image resources, the layers and masks, the additional layer information blocks, the adjustment layer settings, and the shared descriptors, paths and strings.
In the explorer
Drop a .psd or .psb file on this page to open it. The explorer tells the two apart by the
version in the header (1 is a PSD, 2 a PSB) and shows every byte of the file as a node of the structure tree: the
header, the colour mode data (a palette is shown as colours), every image resource, every layer record with its
channels, masks, blending ranges and tagged blocks, and the merged image data. A descriptor is shown item by item
with its keys, types and values, and the text engine data of a type layer is decoded.
- Image tab: the merged picture, the document’s size, mode, depth and resolution, the colour table, each merged channel as a picture, and a report of what could not be decoded.
- Layers tab: a table of every layer (a page of 200 at a time) with its kind (pixel, group, type, smart object, shape, fill or adjustment), size, position, blend mode, opacity and text. A layer’s Show button opens its picture, its masks as pictures and its details in a window.
- Resources tab: every image resource, the thumbnail as a picture, the IPTC datasets, the guides, and the ICC profile, XMP packet and thumbnail JPEG that open as files of their own.
- Composite tab: the layers blended, bottom to top, over the canvas, and a comparison with the merged image (see below).
- Descriptors tab: every descriptor outside the layers as indented text, and the text engine data.
- Patterns and filter effects: the pixel arrays inside patterns (
Patt,Pat2,Pat3) and filter effects (FEid,FXid,FELS) open as pictures from their nodes in the tree.
The Composite tab
The tab blends every visible layer over the canvas with the 27 blend modes of the specification (the colour modes use the W3C and Photoshop formulas, checked against psd-tools for 26 of them; dissolve uses its own noise), with opacity, fill opacity, the layer mask (rectangle, background value, disabled, invert, density), the vector mask (drawn from its path), clipping groups, groups (isolated and pass through), knockout and solid colour fills. It reads only the samples it draws, so the picture size and the Left/Top/Width/Height options bound the memory, not the size of the document. A document whose merged image has no transparency was flattened by Photoshop over white, so the canvas starts white; otherwise it starts transparent.
The merged image is the reference. The tab reports how close the two are (the mean difference, the largest, and the share of samples equal or within 2 levels of 255, both over white) and lists what it did not draw. It is exact for plain stacks of pixel layers and is not claimed exact for anything else: layer styles (drop shadows, strokes, glows, bevels), adjustment layers, gradient and pattern fills, vector strokes, shape path operations (subtract, intersect, exclude), smart filters, Blend If ranges, mask feathering and the exact dissolve noise are not rendered, and layers of 16 and 32 bits are drawn from their 8-bit picture. On the 418 corpus files with layers, the composite equals the merged image in every sample for 113 and is within 2 levels in 99% of the samples for 173. Of the 245 others, 146 list one of the reasons above; 99 are further than 2 levels for a reason the tab cannot name: antialiased edges a few levels apart, shapes and text, and some test files whose merged image does not show their own layers (found for a pair of group-blend files and a note file); they have not been checked one by one.
Colour profile
The option Apply the ICC profile converts the merged picture and layer pictures of RGB and grayscale documents from
the embedded profile (resource 1039) to sRGB. It handles matrix/TRC RGB profiles and gray TRC profiles (curves of the
curv and para types) and agrees with LittleCMS to within 1 level on the 185 corpus files that embed such a profile
(sRGB, Adobe RGB, gamma and dot-gain gray). Profiles that need lookup tables (A2B0: CMYK, Lab and many scanner and printer profiles)
are not applied; CMYK pictures keep the plain conversion and Lab goes through D50, and the decoding report says so. The rendering
intent is fixed (relative colorimetric, no black point compensation).
Pixels are decoded for every colour mode (bitmap, greyscale, indexed, RGB, CMYK, multichannel, duotone and Lab), every depth (1, 8, 16 and 32 bits) and all four compressions: raw, PackBits, ZIP and ZIP with prediction. Only the rows a picture draws are read, so a document of many gigabytes opens at once. A picture of over four million pixels is drawn with every nth pixel; the options bar (Left, Top, Width, Height) chooses a part to draw at full size. A damaged file, with a length that is too large or the end missing, is shown as far as it can be read.
PSB: the Large Document Format
A PSB is the same document with version 2 in the header, sizes up to 300,000 pixels a side, and 8-byte lengths where a PSD has 4.
The structure does not differ in any other way, so it has no pages of its own; the differences are listed where they occur, and the
explorer reads a PSB with its own variant (the registry rows psd and psb both open this page):
- the length of the layer and mask information section and of the layer info inside it, and each channel’s data length in a layer record, are 8 bytes (layers and masks);
- PackBits row byte counts are 4 bytes, in layer channels and in the merged image (header and image data);
- the length of an additional layer information block is 8 bytes for the keys
LMsk,Lr16,Lr32,Layr,Mt16,Mt32,Mtrn,Alph,FMsk,lnk2,FEid,FXid,PxSDand, as files show, others (additional layer information); filter effects already use 8-byte lengths in both versions.
Not described
The pages follow Adobe’s Photoshop File Formats Specification. Adobe leaves some structures to its plug-in SDK and its API Guide, which are not public. Where the specification is silent the pages use psd-tools, ag-psd, ExifTool and the other readers, and say which.
Known, not yet covered
- Reference: the layout of image resource 1030 (JPEG quality) comes from ExifTool’s table (and its tag 0x0406); GIMP, psd-tools and ag-psd only name it, and no file here has it; ZIP-compressed image data in the merged image is read as one stream for all channels, and no file here has it (image resources, header).
- Viewer: the Composite tab does not draw layer styles, adjustment layers, gradient and pattern fills, vector strokes, shape path operations, smart filters, Blend If ranges or mask feathering, approximates knockout and dissolve, and draws 16-bit and 32-bit layers from 8 bits; the merged image is the reference and the tab reports the difference.
- Viewer: the ICC profile is applied only for RGB matrix/TRC and gray profiles; profiles with lookup tables (CMYK, Lab) are not, and the decoding report says so.
- Viewer: the Composite tab and pattern pictures are checked against psd-tools and Pillow on the corpus, not against Photoshop itself.
Unknown
- Reference: image resources 1018 (duotone image information), 1021 (EPS options), 1029 (raw image mode), 1070 (HDR toning), 1071 (print information) and the data of 1043 (spot halftone) beyond its length field: no layout is published in the specification, psd-tools, ag-psd (which keeps 1018 as bytes), ExifTool (which lists them as unknown) or GIMP (which only names them). The viewer shows them as labelled bytes (image resources). Resources 1092 and 1097, which the specification does not list, are decoded from ag-psd’s layout.
- Reference: the slice origin, type and alignment values (no source gives them); the 36 bytes after the ranges of
hue2; the 15 bytes after the data of a version 2 linked file; the keysAlphandPxSD; the colour mode data of a duotone that is not 524 bytes. The viewer shows them as labelled bytes. Thevowvkey, theCAIkey and themdynitem ofshmdare decoded from ag-psd’s readers.
Links
Software
- Adobe Photoshop – Adobe’s image editor, whose native format is PSD (Windows, macOS)
- Photopea – online image editor that opens and saves PSD with its layers (web browser)
- GIMP – free image editor that opens and exports PSD layers (Windows, macOS, Linux)
- Krita – free painting program that opens and saves PSD (Windows, macOS, Linux)
- Affinity Photo – image editor that opens and exports PSD (Windows, macOS, iPad)
- XnView MP – image viewer and converter that shows the flattened image (Windows, macOS, Linux)
- ImageMagick – command-line tool that converts PSD and reads its layers (Windows, macOS, Linux)
Developers
- psd-tools – library that reads PSD layers and the composite image (Python)
Reference
- Adobe Photoshop File Formats Specification – Adobe’s published specification of PSD and PSB