kra-d
is a port of libkra to D to support basic extraction of layer info and layer data from krita files.
dxml
by jmdavis is required
To parse a Krita document, use parseDocument
in kra
.
KRA document = parseDocument("myFile.kra");
To extract layer data (textures) from a layer use Layer.extractLayerImage()
KRA doc = parseDocument("myfile.kra");
foreach(layer; doc.layers) {
// Skip non-image layers
if (layer.type != LayerType.Any) continue;
// Extract the layer image data.
// The output RGBA output is stored in Layer.data
layer.extractLayerImage();
// write_image from imagefmt is used here to export the layer as a PNG
write_image(buildPath(outputFolder, layer.name~".png"), layer.width, layer.height, layer.data, 4);
}
- Add support to Colorize Mask
- Only support for 'RGBA 8bit integer' documents
- Unsupported Transparency Mask
- Unsupported Filter Mask
- Unsupported Transform Mask
Thanks to LunaTheFoxgirl for the inspiration for the project.