Introduction
XCF is the native format of GIMP, the free image editor. The name comes from the eXperimental Computing Facility at the University of California, Berkeley, where GIMP was started. An XCF file keeps everything GIMP needs to carry on editing: layers, layer groups, channels, masks, paths, guides, the selection and the image’s settings.
The format has grown with GIMP through numbered versions; newer versions add high bit
depths and 64-bit offsets for large images. GIMP also opens XCF files compressed with gzip,
bzip2 or xz, saved as .xcf.gz, .xcf.bz2 or
.xcf.xz.
Structure
An XCF file starts with the text gimp xcf and a version: file
for version 0, or v001, v002 and so on, ended by a zero byte. The
image width, height and base type (RGB, greyscale or indexed) follow, and from version 4
the precision. All numbers are big-endian.
A list of image properties comes next, then a list of pointers to the layers and a list of pointers to the channels (and, from version 18, to the paths), each ended by a zero pointer. Every layer has its own properties and points to a hierarchy of pixel data, which is stored in tiles of 64 by 64 pixels, uncompressed or compressed with run-length encoding or zlib.
0Signaturegimp xcfand the version14 bytes14Canvas width, height, base type, precision12 or 16 bytes…Image properties colour map, compression, resolution, guides, parasitesvaries…Layer and channel pointers each list ends with zerovaries…Layers properties, then tiled pixel datavaries
The full layout is in the reference pages: the header and every version, the properties, and the layers, channels, tiles, effects and paths.
In the explorer
Drop a .xcf file on this page to open it. Every version is read, from file (version 0) to v027, with 4-byte pointers up to
version 10 and 8-byte pointers from version 11. The tabs are:
- Image: the visible layers composited, and the image’s facts (canvas, colour model, precision, compression, resolution, layer, channel and path counts, comment).
- Layers: every layer, groups indented by their item path, with size, position, mode, opacity, visibility and mask; each opens its own picture, its mask and its
details (every property, effects, parasites, and for a text layer its text, font and size from the
gimp-text-layerparasite). Vector and link layers show their settings. - Channels: the selection mask, the channels and the layer masks, each with its picture, and the effects of layers.
- Paths: every path and stroke (both the version 18 structure and
PROP_VECTORSorPROP_PATHS), and a picture of them. - Properties: the image’s properties by name and meaning, guides, sample points, the colour map and units.
- Parasites: every parasite of the image, layers, masks, channels and paths with its data as text or bytes; an ICC profile opens as a file.
- Tiles: each drawable’s hierarchy, level and tile data, and a check that decodes every tile (up to 20,000 tiles are checked when the file opens).
- Rendering: which layer modes are drawn exactly, approximately or not at all, and what the composite leaves out.
The tree lists every structure in the order it lies in the file; the tile pointers and the tiles of a level are lists, so an image of any size opens. Tiles are decoded only when a picture needs them, a band of rows at a time, uncompressed, with RLE or with zlib, at 8, 16 and 32-bit integer and 16, 32 and 64-bit floating-point precision, linear, non-linear or perceptual. A picture of more than four million pixels is drawn with every nth pixel. The samples of versions 7 to 11 wider than 8 bits were stored in the byte order of the machine that saved them, which the file does not record; the viewer assumes little-endian and says so.
The composite follows GIMP’s source (gimpoperationnormal.c, gimpoperationlayermode.c and its blend and composite files): layers from the bottom up, each with
its offset, opacity, mask and mode, in the colour space the mode asks for, and a group as one layer. Of the 62 layer modes:
- Drawn with GIMP’s own formulas (27): Normal (28) and Normal legacy (0, which GIMP composites in non-linear space), Overlay (23), Multiply, Screen, Difference, Addition, Subtract, Darken only, Lighten only, Hue (HSV), Saturation (HSV), Colour (HSL), Value (HSV), Divide, Dodge, Burn, Hard light, Soft light, Grain extract, Grain merge, Vivid light, Pin light, Linear light, Hard mix, Exclusion and Linear burn (30 to 53). The four composite modes (union, clip to backdrop, clip to layer, intersection) are all drawn. The formulas are tested here against an independent implementation of the same formulas. No picture made by GIMP was available to compare with, so nothing is claimed beyond that, and the sRGB curve stands in for the transfer curve of the image’s colour space (an embedded ICC profile is not applied).
- Drawn approximately (29): the legacy modes 2 to 21 (GIMP’s legacy operations were not read; each is drawn with the formula of the same name in non-linear space), Behind (29), the LCh modes (24 to 27) and Luma darken only, Luma lighten only and Luminance (54 to 56), whose colour conversions are assumed, and Pass through (61).
- Not drawn (6): Dissolve (1, a random pattern), Colour erase (22 and 57), Erase (58), Merge (59) and Split (60). The layer is left out and the Rendering tab says so.
The bottommost visible layer is drawn as Normal, as the format’s documentation says GIMP does. Layer effects (non-destructive filters) are listed but not applied. Text, vector and link layers are drawn from the pixels stored in the file, not rendered again from their text, path or linked file.
Not described
The pages follow the GIMP developer documentation and GIMP’s own source (xcf-private.h, xcf-load.c, gimpimage.c).
Known, not yet covered
- Viewer: the composite draws 27 of the 62 layer modes with GIMP’s formulas, 29 approximately and 6 not at all (listed above and on the Rendering tab), is tested against an independent implementation of those formulas and not against a picture made by GIMP, applies no ICC profile, and does not apply layer effects or render text, vector and link layers again.
- Viewer: samples wider than 8 bits in versions 7 to 11 are read as little-endian, which is a guess (the format does not record the byte order); the only public sample file is GIMP’s own version 0 test file, so versions 12 and later, high precisions, groups, effects and the other newer structures are checked only against files made by a writer written from the documentation.
Unknown
- Reference: the exact changes of versions 4, 5 and 6, inferred from the precision tables of development releases (header).
- Reference: parasites added after GIMP 2.10: no public registry exists.
- Reference: the statement that blend modes 0 to 22 are legacy and 23 and above linear comes from general GIMP knowledge, not a read source (properties).
Links
Software
- GIMP – free image editor whose native format is XCF (Windows, macOS, Linux)
- Krita – free painting program that opens XCF files (Windows, macOS, Linux)
- Photopea – online image editor that opens XCF files (web browser)
- XnView MP – image viewer and converter that opens XCF (Windows, macOS, Linux)
- ImageMagick – command-line tool that converts XCF to other formats (Windows, macOS, Linux)
Reference
- XCF file format – the format’s documentation on GIMP’s developer site
- xcf.txt – the older copy of the description in GIMP’s source tree