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. |
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 | Not laid out in the specification. |
indx | Index | Not laid out in the specification. |
name | Name | 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. Adobe does not publish
a complete list; the names used by each block follow Photoshop’s scripting
documentation.