There is no written specification of KRA. This page is taken from Krita’s source code
(the tag names in kis_kra_tags.h, the tile code in
libs/image/tiles3, the composite op registry) and the Krita wiki’s note
on the tile data format, with an independent reader (the Rust crate
krita) as a check.
Archive
A KRA file is a zip archive. Paths below that start with name/ use the
image’s name attribute from maindoc.xml as a folder.
| Entry | Contents |
|---|---|
mimetype | First and stored uncompressed: application/x-krita. |
maindoc.xml | The image and its tree of layers and masks, below. |
documentinfo.xml | Title, author and other document information. |
mergedimage.png | The flattened image, for other programs. |
preview.png | A small thumbnail. |
name/layers/file | Pixel data of a paint layer or mask, in the tile format below. file is the layer’s filename attribute, such as layer2. |
… .defaultpixel | The colour of every pixel no tile covers, one pixel’s bytes. |
… .icc | The layer’s colour profile when it differs from the image’s. |
… .filterconfig | Settings of a filter mask, adjustment or generator layer. |
… .transformconfig | Settings of a transform mask. |
… .pixelselection, .shapeselection | The selection of a selection mask, or of an adjustment or generator layer. |
… .shapelayer/content.svg | The shapes of a vector layer, as SVG. |
… .colorizemask | Data of a colorise mask. |
… .metadata | Layer metadata. |
name/annotations/icc | The image’s ICC colour profile. |
name/annotations/proofing/icc | The soft-proofing profile. |
name/annotations/exif | Exif metadata. |
name/annotations/layerstyles.asl | Layer styles, in Photoshop’s ASL format. |
name/assistants/ | Drawing assistants. |
name/palettes/ | Palettes stored with the document. |
name/storyboard/, /audio/, /animation/ | Storyboard, audio track and animation metadata. |
name/shapelayers/ | Older location of vector layer data. |
resources/ | Brushes, patterns and other resources embedded in the document. |
maindoc.xml
<DOC xmlns="http://www.calligra.org/DTD/krita" syntaxVersion="2" kritaVersion="5.2.2" editor="Krita">
<IMAGE name="Unnamed" mime="application/x-kra" width="1920" height="1080"
colorspacename="RGBA" profile="sRGB-elle-V2-srgbtrc.icc" x-res="300" y-res="300">
<layers>
<layer name="Paint Layer 1" filename="layer2" nodetype="paintlayer" compositeop="normal"
opacity="255" visible="1" locked="0" x="0" y="0" uuid="{…}" colorspacename="RGBA"/>
</layers>
</IMAGE>
</DOC>
DOC and IMAGE
| Attribute | Meaning |
|---|---|
DOC syntaxVersion | Version of this XML, 2 in current files. |
DOC kritaVersion, editor | The Krita version and program that saved it. |
IMAGE name | Image name; also the folder of its data in the archive. |
IMAGE mime | application/x-kra. |
IMAGE width, height | Canvas size in pixels. |
IMAGE colorspacename | Colour model and depth, such as RGBA (8-bit RGB with alpha) or RGBA16. |
IMAGE profile | Name of the colour profile. |
IMAGE x-res, y-res | Resolution in pixels per inch. |
IMAGE description | Description. |
Inside IMAGE there may also be elements for the projection background
colour, colour history, palettes, mirror axis, proofing settings, animation and HDR
metadata.
Layer and mask attributes
Layers sit in layers as layer elements, top first; a group
layer holds its own layers; a layer’s masks sit in masks as
mask elements.
| Attribute | Meaning |
|---|---|
name | Name shown in the Layers docker. |
filename | Base name of the layer’s files in the archive. |
nodetype | The kind of layer or mask, below. |
uuid | Unique ID, in braces. |
visible, locked, collapsed | 0 or 1. |
opacity | 0 to 255. |
compositeop | Blend mode, from the list below. |
x, y | Offset of the layer’s pixels. |
colorspacename | The layer’s colour space. |
channelflags, channellockflags | Which channels are active and which are locked, one character per channel. |
colorlabel | Colour label number, 0 for none. |
selected, active | Selection and active state in the user interface. |
intimeline, onionskin, keyframes | Animation: shown in the timeline, onion skins on, and the name of the keyframes file. |
passthrough | A group layer in pass-through mode. |
layerstyle | UUID of the layer style in layerstyles.asl. |
filtername, filterversion | Filter of a filter mask or adjustment layer. |
generatorname, generatorversion | Generator of a fill layer. |
clonefrom, clonefromuuid, clonetype | Source of a clone layer. |
show-coloring, edit-keystrokes, use-edge-detection, edge-detection-size, fuzzy-radius, cleanup, limit-to-device | Settings of a colorise mask. |
Node types
nodetype | Node |
|---|---|
paintlayer | Paint layer: pixels. |
grouplayer | Group. |
shapelayer | Vector layer: SVG shapes. |
adjustmentlayer | Filter layer: a filter applied to what is below. |
generatorlayer | Fill layer: a generated colour or pattern. |
clonelayer | Clone of another layer. |
filelayer | A layer that shows an outside image file. |
referenceimages | Reference images. |
transparencymask | Mask that sets the layer’s transparency. |
filtermask | Mask that applies a filter. |
selectionmask | A saved selection. |
transformmask | Mask that transforms the layer. |
colorizemask | Colorise mask, which fills line art from strokes. |
Composite op names
The values of compositeop, as Krita’s composite op registry names them.
The most common are normal, multiply, screen,
overlay, darken, lighten, dodge,
burn, add, subtract, diff,
soft_light, hard_light, hue,
saturation, color, luminize and
pass through. The full list:
normal, erase, in, out, alphadarken, destination-in, destination-atop, xor, or, and, nand, nor, xnor, implication, not_implication, converse, not_converse, plus, minus, add, subtract, inverse_subtract, diff, multiply, divide, arc_tangent, geometric_mean, additive_subtractive, negation, modulo, modulo_continuous, divisive_modulo, divisive_modulo_continuous, modulo_shift, modulo_shift_continuous, equivalence, allanon, parallel, grain_merge, grain_extract, exclusion, hard mix, hard_mix_hdr, hard_mix_photoshop, hard_mix_softer_photoshop, overlay, behind, greater, hard overlay, hard_overlay_hdr, interpolation, interpolation 2x, penumbra a, penumbra b, penumbra c, penumbra d, marker, darken, burn, linear_burn, gamma_dark, shade_ifs_illusions, fog_darken_ifs_illusions, easy burn, lighten, dodge, dodge_hdr, linear_dodge, screen, hard_light, soft_light_ifs_illusions, soft_light_pegtop_delphi, soft_light (Photoshop’s formula), soft_light_svg, gamma_light, gamma_illumination, vivid_light, vivid_light_hdr, flat_light, linear light, pin_light, pnorm_a, pnorm_b, super_light, tint_ifs_illusions, fog_lighten_ifs_illusions, easy dodge, luminosity_sai, hue, color, tint, saturation, inc_saturation, dec_saturation, luminize, inc_luminosity, dec_luminosity, hue_hsv, color_hsv, saturation_hsv, inc_saturation_hsv, dec_saturation_hsv, value, inc_value, dec_value, hue_hsl, color_hsl, saturation_hsl, inc_saturation_hsl, dec_saturation_hsl, lightness, inc_lightness, dec_lightness, hue_hsi, color_hsi, saturation_hsi, inc_saturation_hsi, dec_saturation_hsi, intensity, inc_intensity, dec_intensity, copy, copy_red, copy_green, copy_blue, tangent_normalmap, colorize, bumpmap, combine_normal, clear, dissolve, displace, nocomposition, pass through, darker color, lighter color, undefined, reflect, glow, freeze, heat, glow_heat, heat_glow, reflect_freeze, freeze_reflect, heat_glow_freeze_reflect_hybrid, lambert_lighting, lambert_lighting_gamma2.2.
Layer pixel data
Each paint layer’s data file is a short text header followed by tiles. The header is lines of a keyword, a space and a number:
VERSION 2
TILEWIDTH 64
TILEHEIGHT 64
PIXELSIZE 4
DATA 10
0,0,LZF,3517
(3517 bytes)
64,0,LZF,1204
(1204 bytes)
…
| Line | Meaning |
|---|---|
VERSION | Format version, 2. A file whose first line does not start with V is the older version 1 format, whose first line is just the number of tiles. |
TILEWIDTH, TILEHEIGHT | Tile size, 64 by 64. |
PIXELSIZE | Bytes per pixel of the layer’s colour space: for RGBA, 4 at 8 bits, 8 at 16 bits, 16 at 32-bit float. |
DATA | Number of tiles that follow. |
Each tile is a text line x,y,LZF,size and then size bytes.
x and y are the pixel position of the tile’s top-left corner. Pixels that no tile
covers take the value in the .defaultpixel file.
| Bytes | Contents |
|---|---|
| 1 | Flag: 1 the rest is LZF-compressed, 0 it is stored raw (used when compression would not make it smaller). |
size − 1 | The tile’s 64 × 64 × PIXELSIZE bytes, compressed or raw. |
Before compression the bytes are rearranged by position within the pixel: all the first bytes of the 4096 pixels, then all the second bytes, and so on. A reader reverses this after decompressing. For 8-bit RGBA the pixel bytes are stored in the order blue, green, red, alpha, as Krita holds them in memory.