Several structures appear in many places in a PSD file: strings, colours, the path records of saved paths and vector masks, and the Action descriptor, a typed key and value tree that newer Photoshop features use for almost everything. Numbers are big-endian.
Strings
| Kind | Layout |
|---|---|
| Pascal string | A 1-byte length, then that many bytes of text. Padded to an even total in resource names, and to a multiple of 4 in layer names. |
| Unicode string | A 4-byte count of UTF-16 code units (not bytes), then the characters, two bytes each, big-endian. The specification says the string ends with a two-byte null; readers should strip a trailing null if the count includes one. |
| ID (in descriptors) | A 4-byte length, then that many ASCII characters; or, when the length is 0, a 4-byte key such as Clr . |
Colour
Ten bytes: a 2-byte colour space ID, then four 2-byte components. Unused components are zero.
| ID | Colour space | Components |
|---|---|---|
| 0 | RGB | Red, green, blue, each 0 to 65535. |
| 1 | HSB | Hue, saturation, brightness, each 0 to 65535. |
| 2 | CMYK | Cyan, magenta, yellow, black, each 0 to 65535, where 0 is 100% ink. |
| 3 | Pantone | Custom colour; data undocumented. |
| 4 | Focoltone | Custom colour; data undocumented. |
| 5 | Trumatch | Custom colour; data undocumented. |
| 6 | Toyo 88 | Custom colour; data undocumented. |
| 7 | Lab | Lightness 0 to 10000; a and b −12800 to 12700 (signed). |
| 8 | Greyscale | Grey 0 to 10000. |
| 10 | HKS | Custom colour; data undocumented. |
Path records
Saved paths (image resources 2000 to 2997), the working path (1025) and vector masks
(vmsk) are lists of 26-byte records. Each starts with a 2-byte selector.
| Selector | Record | Contents |
|---|---|---|
| 0 | Closed subpath length | Number of knot records that follow (2 bytes), then 22 zero bytes. |
| 1 | Closed subpath Bézier knot, linked | Three points, below. |
| 2 | Closed subpath Bézier knot, unlinked | Three points. |
| 3 | Open subpath length | Number of knot records that follow, then zeros. |
| 4 | Open subpath Bézier knot, linked | Three points. |
| 5 | Open subpath Bézier knot, unlinked | Three points. |
| 6 | Path fill rule | The first record of a path. 24 zero bytes. Paths are filled with the even-odd rule. |
| 7 | Clipboard | Top, left, bottom, right and a resolution, each a 4-byte fixed-point number, then 4 zero bytes. |
| 8 | Initial fill rule | A 2-byte value, 0 or 1; 1 means the fill starts with all pixels. The rest is zero. |
A knot holds three points of 8 bytes: the control point for the segment entering the knot, the anchor point, and the control point for the segment leaving it. A point is two signed 32-bit fixed-point numbers, vertical first, with 8 integer bits and 24 fraction bits. They are fractions of the image size: (0, 0) is the top left corner and (1, 1) the bottom right. “Linked” knots are smooth: their two control points move together.
00 01 00 80 00 00 00 40 00 00 00 80 00 00 00 80 00 00
00 80 00 00 00 C0 00 00
Descriptor
A descriptor is a class with a list of keyed items. It is usually preceded by a 4-byte descriptor version, which is 16.
| Size | Type | Name | Description |
|---|---|---|---|
| varies | Unicode string | Name | Class name, often empty. |
| varies | ID | ClassID | Class ID. |
| 4 | u32 | Count | Number of items. |
| varies | ID | Key | For each item: its key. |
| 4 | char[4] | Type | For each item: its type, below. |
| varies | Value | For each item: its value. |
Item types
| Type | Meaning | Value layout |
|---|---|---|
obj | Reference | A 4-byte count, then reference items (below). |
Objc | Descriptor | A nested descriptor. |
GlbO | Global object | A nested descriptor. |
VlLs | List | A 4-byte count, then for each item a 4-byte type and its value. |
doub | Double | 8-byte IEEE double. |
UntF | Unit float | A 4-byte unit key (below), then an 8-byte double. |
TEXT | String | A Unicode string. |
enum | Enumerated | A type ID, then an enumeration value ID. |
long | Integer | 4 bytes, signed. |
comp | Large integer | 8 bytes. |
bool | Boolean | 1 byte. |
type | Class | A Unicode name, then a class ID. |
GlbC | Class | A Unicode name, then a class ID. |
alis | Alias | A 4-byte length, then an FSSpec on the Mac or a full path on Windows. |
tdta | Raw data | A 4-byte length and the bytes. Used, for example, for the text engine data of type layers (text engine data). |
UnFl | Array of unit floats | A 4-byte unit key, a 4-byte count, then that many 8-byte doubles. Not listed in Adobe’s specification. |
ObAr | Object array | A 4-byte item count, then a descriptor. Not listed in Adobe’s specification. |
Pth | Path | A 4-byte length and bytes. Not listed in Adobe’s specification. |
Keys, class IDs and enumerations
A key, class ID, type ID or enumeration value is a 4-byte length followed by that many characters; when the
length is 0, four characters follow. The four-character form is Photoshop’s own code (Opct for
opacity, Clr for colour); the longer form is a name such as textKey or
EngineData. A string (TEXT and every name) is a Unicode string: a 4-byte count of UTF-16 units,
which usually includes a final zero unit (an empty string can be a count of 0), and the units.
Reference items
| Key | Meaning | Layout |
|---|---|---|
prop | Property | Unicode name, class ID, key ID. |
Clss | Class | Unicode name, class ID. |
Enmr | Enumerated reference | Unicode name, class ID, type ID, enumeration ID. |
rele | Offset | Unicode name, class ID, 4-byte offset. |
Idnt | Identifier | A 4-byte signed integer. (Not laid out in the specification.) |
indx | Index | A 4-byte signed integer. (Not laid out in the specification.) |
name | Name | Unicode name, class ID, Unicode string. (Not laid out in the specification.) |
Units of unit floats
| Key | Unit |
|---|---|
#Ang | Angle, in degrees. |
#Rsl | Density (resolution), per inch. |
#Rlt | Distance, at 72 pixels per inch. |
#Nne | None; a plain number. |
#Prc | Percent. |
#Pxl | Pixels. |
#Pnt | Points. |
#Mlm | Millimetres. |
Descriptor keys and class names are Photoshop’s scripting identifiers, such as
Clr , Opct or textKey. The viewer names the keys of
Photoshop’s scripting terminology: a vetted list of common keys first (opacity, angle, distance, bevel
settings, colours), then the full tables of Adobe’s Photoshop SDK headers (PITerminology.h and
PIStringTerminology.h) as psd-tools carries them: 772 keys, 193 classes, 634 enumerated values,
220 events, 159 types, 8 units and 6 forms (the words of each name are the SDK’s CamelCase identifier split).
The tables are made by scripts/psd/make-terms.py and checked by a second program that reads the
same source a different way. A code that none of the tables lists (many plug-in and newer Photoshop keys) is
shown by its code; the meaning of a key is decided by the block that holds the descriptor.