Adobe Photoshop_ 2.5 File Format
1992 Thomas Knoll
1993 Adobe Systems, Inc.
Photoshop 2.5 format was designed to be fast and easy to read and
write, while solving a couple of problems with Photoshop 2.0 format:
(1) It is data fork only, thus cross-platform.
(2) It uses optional RLE compression, so simple images and mask channels can
be saved much more compactly.
The Macintosh file type code is '8BPS'. The DOS extension is '.PSD'. All
information is stored in big-endian byte order, so little-endian machines
will have to swap bytes when reading and writing.
The following sections describe the information stored in the file's data
fork, in order.
1. Signature (4 bytes)
Always equal to '8BPS' for this format. Do not try to read the file if
the signature does not match this value.
2. Version (2 bytes)
Always equal to 1 for this format. Do not try to read the file if the
version number does not match this value.
3. Reserved (6 bytes)
Readers should ignore these bytes, and writers should write zeros.
4. Channels (2 bytes)
The number of channels in the image, including any alpha channels. Supported
range is 1 to 16 for Photoshop 2.5.
5. Rows (4 bytes)
The height of the image in pixels. Supported range is 1 to 30000 for
6. Columns (4 bytes)
The width of the image in pixels. Supported range is 1 to 30000 for
7. Depth (2 bytes)
The number of bits per channel. Supported values are 1 and 8 for
8. Mode (2 bytes)
The color mode of the file. Supported values are: Bitmap = 0, Grayscale = 1,
Indexed Color = 2, RGB Color = 3, CMYK Color = 4, Multichannel = 7,
Duotone = 8, Lab Color = 9.
9. Mode Data (4 byte length + variable)
Contains the required data to define the color mode.
For indexed color images, the count will be equal to 768, and the mode data
will contain the color table for the image, in non-interleaved order.
For duotone images, the mode data will contain the duotone specification,
the format of which is not documented. Non-Photoshop readers can treat
the duotone image as a grayscale image, and keep the duotone specification
around as a black box for use when saving the file.
For all other modes, the byte count is zero.
10. Image Resources (4 byte length + variable)
Contains a Photoshop 2.5 image resources block, the format of which is
documented separately. Information contained in this block includes
the image's resolution, and pen tool paths.
11. Reserved Data (4 byte length + variable)
Reserved for future use. Readers should skip this, and writers should write
a zero length block.
12. Compression (2 bytes)
Two values are currently define: 0 = Raw Data, 1 = RLE compressed.
13. Image Data (variable)
Image data is stored in planar order, e.g. all the red data, all the green
data, etc. Each plane is stored in scanline order, with no pad bytes.
If the compression code is 0, the image data is just the raw image data.
If the compression code is 1, the image data starts with the byte counts
for all the scan lines (rows * channels), with each count stored as a
two-byte value. The RLE compressed data follows, with each scan
line compressed separately. The RLE compression is the same compression
algorithm used by the Macintosh ROM routine PackBits, and the TIFF standard.