An XCF file starts with a signature and a version tag, the canvas size and type, and a list of image properties. Pointer lists then lead to the layers, channels and paths. GIMP’s developer site documents the format. GIMP writes the lowest version that can hold the features an image uses, so most files are not the newest version.
00000000 67 69 6D 70 20 78 63 66 20 76 30 31 31 00 00 00
00000010 02 00 00 00 01 80 00 00 00 00 00 00 00 96
Basic types
All numbers are big-endian and need not be aligned.
| Type | Size | Encoding |
|---|---|---|
UINT32, INT32 | 4 | Unsigned, or two’s-complement signed. |
FLOAT | 4 | IEEE 754 single precision. |
STRING | 4 + n + 1 | A UINT32 giving n + 1, then n bytes of UTF-8, then a zero byte. An empty string is just a UINT32 0. |
POINTER | 4 or 8 | Byte offset from the start of the file. 4 bytes up to version 10, 8 bytes from version 11. |
GeglColor | varies | A STRING naming the babl pixel format, a UINT32 size and the colour bytes, then a UINT32 ICC profile size and the profile, if any. From GIMP 3.2 a missing colour is a UINT32 0. |
RESOURCE | varies | A STRING name, a STRING collection identifier and a UINT32 internal flag (version 24 and later). A missing resource is a UINT32 0. |
File header
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 9 | bytes | magic | gimp xcf with a trailing space. |
| 9 | 4 | bytes | version | file for version 0; otherwise v and three digits, such as v001 or v011. |
| 13 | 1 | byte | terminator | 0. |
| 14 | 4 | UINT32 | width | Canvas width in pixels. |
| 18 | 4 | UINT32 | height | Canvas height in pixels. |
| 22 | 4 | UINT32 | base_type | 0 RGB, 1 greyscale, 2 indexed. |
| 26 | 4 | UINT32 | precision | Version 4 and later only. Codes below. |
| 26 or 30 | varies | property list | properties | Image properties, ended by PROP_END. |
| varies | POINTER[] | layers | Pointers to the layers, top layer first, ended by a 0 pointer. | |
| varies | POINTER[] | channels | Pointers to the channels, in no particular order, ended by a 0 pointer. | |
| varies | POINTER[] | paths | Version 18 and later: pointers to the paths, ended by a 0 pointer. |
Each property is a UINT32 type, a UINT32 payload length and
the payload. A reader skips types it does not know by their length; a few old
properties store an unreliable length, noted on the
properties page.
Precision
| Versions 7 and later | Versions 5 and 6 | Version 4 | Precision |
|---|---|---|---|
| 100 | 100 | 8-bit linear integer | |
| 150 | 150 | 0 | 8-bit gamma (perceptual) integer |
| 200 | 200 | 16-bit linear integer | |
| 250 | 250 | 1 | 16-bit gamma integer |
| 300 | 300 | 2 | 32-bit linear integer |
| 350 | 350 | 32-bit gamma integer | |
| 500 | 400 | 3 | 16-bit linear floating point |
| 550 | 450 | 16-bit gamma floating point | |
| 600 | 500 | 4 | 32-bit linear floating point |
| 650 | 550 | 32-bit gamma floating point | |
| 700 | 64-bit linear floating point | ||
| 750 | 64-bit gamma floating point |
Versions 0 to 3 have no precision field; they are always 8-bit gamma integer. Indexed images are always 8-bit.
Versions
The feature in each row is what makes GIMP write that version. Versions 4, 5, 6, 10, 20 and 21 were written by development releases or are reached only on the way to a later one; GIMP no longer writes them.
| Version | Tag | First GIMP | Added |
|---|---|---|---|
| 0 | file | 0.99.16 | The original format. |
| 1 | v001 | 0.99.16 | Colour maps (PROP_COLORMAP) for indexed images. |
| 2 | v002 | 1.3.10 | Layer modes soft light, grain extract, grain merge, and colour erase as a paint mode. |
| 3 | v003 | 2.7.1 (2.8) | Layer groups. |
| 4 | v004 | 2.9 development | The precision field (first set of codes). |
| 5, 6 | v005, v006 | 2.9 development | Second set of precision codes, with linear and gamma variants. |
| 7 | v007 | 2.10 | Current precision codes; any precision other than 8-bit gamma integer. |
| 8 | v008 | 2.10 | zlib tile compression. |
| 9 | v009 | 2.10 | Overlay and the LCH layer modes (23 to 27). |
| 10 | v010 | 2.10 | Layer modes 28 to 61. Always raised to 11 when saving. |
| 11 | v011 | 2.10 | 8-byte pointers, for images of 4 GB and more. |
| 12 | v012 | 2.10 | Corrected byte order of samples wider than 8 bits. |
| 13 | v013 | 2.10 | Masks on layer groups. |
| 14 | v014 | 3.0 | Several selected layers (PROP_ACTIVE_LAYER on more than one). |
| 15 | v015 | 3.0 | Guides outside the canvas. |
| 16 | v016 | 3.0 | Several selected channels; item sets (PROP_ITEM_SET, PROP_ITEM_SET_ITEM) replace PROP_LINKED. |
| 17 | v017 | 3.0 | PROP_LOCK_VISIBILITY; position and alpha locks on groups. |
| 18 | v018 | 3.0 | Paths stored as their own structures with properties: several selected paths, colour tags and locks on paths. |
| 19 | v019 | 3.0 | New font information in text layers. |
| 20 | v020 | 3.0 | Layer effects. |
| 21 | v021 | 3.0 | PROP_USER_UNIT without singular and plural names. |
| 22 | v022 | 3.0 | A version string in each effect; files with layer effects are written as 22. |
| 23 | v023 | 3.0 | The “RGB (perceptual)” value of composite and blend space. |
| 24 | v024 | 3.2 | Vector layers (PROP_VECTOR_LAYER) and the RESOURCE type. |
| 25 | v025 | 3.2 | Link layers (PROP_LINK_LAYER) and PROP_TRANSFORM. |
| 26 | v026 | 3.2.6 | Effects on channels and layer masks. |
| 27 | v027 | 3.4 | Text layers with a transformation other than the identity. |
GIMP also opens XCF files compressed as a whole with gzip, bzip2 or xz
(.xcf.gz, .xcf.bz2, .xcf.xz); inside they are
ordinary XCF.