An OpenEXR file starts with a magic number, a version field and one or more headers of attributes. The values are described on the attribute types page, and the offset tables and chunks come after the headers. All numbers are little-endian.
Magic number and version
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | int | magic | 20000630, the bytes 76 2F 31 01. |
| 4 | 4 | bit field | version | The format version and flags, below. |
| Bits | Mask | Meaning |
|---|---|---|
| 0 to 7 | 0xFF | The format version. The current version is 2. |
| 9 | 0x200 | A single-part tiled file. Bits 11 and 12 must be 0. |
| 10 | 0x400 | Long names: attribute names and types may be up to 255 bytes, not 31. |
| 11 | 0x800 | The file contains non-image (deep) parts. |
| 12 | 0x1000 | A multi-part file. |
| The other 19 bits | Must be 0. |
Kinds of file
| Layout | Bit 9 | Bit 11 | Bit 12 |
|---|---|---|---|
| Single-part scan line | 0 | 0 | 0 |
| Single-part tiled | 1 | 0 | 0 |
| Multi-part, images only | 0 | 0 | 1 |
| Single-part deep | 0 | 1 | 0 |
| Multi-part with deep parts | 0 | 1 | 1 |
Attributes
A header is a list of attributes ended by a zero byte. Each attribute is:
| Field | Type | Description |
|---|---|---|
| Name | zero-terminated text | 1 to 31 bytes, or 1 to 255 if bit 10 is set. |
| Type | zero-terminated text | The name of the value type, same length limits. |
| Size | int | The length of the value in bytes. |
| Value | Size bytes | The value, laid out as its type says. |
A single-part file has one header and no extra zero byte after it. A multi-part file has one header per part, followed by one extra zero byte, an empty header.
Attributes every file needs
| Name | Type |
|---|---|
channels | chlist |
compression | compression |
dataWindow | box2i |
displayWindow | box2i |
lineOrder | lineOrder |
pixelAspectRatio | float |
screenWindowCenter | v2f |
screenWindowWidth | float |
Attributes needed in some files
| Name | Type | When |
|---|---|---|
tiles | tiledesc | Tiled parts (tiledimage, deeptile). |
name | string | Multi-part or non-image files, where bit 11 or 12 is set. |
type | string | The same files. One of scanlineimage, tiledimage, deepscanline, deeptile, agreeing with bits 9 and 11. |
version | int | Deep parts, value 1; otherwise assumed to be 1. |
chunkCount | int | Multi-part or non-image files. |
maxSamplesPerPixel | int | Deep files. Deprecated: the library ignores it. |
view | text | Optional, for multi-part files. |
Rules across parts
displayWindowandpixelAspectRatiomust be in every part and must match across parts.timecodeandchromaticitiesare optional. Where they appear in more than one part, the values must match.- By convention, attributes for the whole file go in part 0.
Windows and sampling
The displayWindow is the rectangle shown to the viewer. The
dataWindow marks where pixel data exists; it may be smaller than the
display window or extend beyond it. A channel with sampling rates
sx and sy stores data only for pixels where
x mod sx = 0 and y mod sy = 0.