Clean up Krita layers and batch-export sprite sheets and PNGs

Updated 2026-11-28 · MCP Pro for Krita 1.0.0

Half of game-art work in a painting program is bookkeeping: layers called Paint Layer 37, empty groups, hidden leftovers, and the same export dialog fifty times. That is the part an AI does well, and MCP Pro for Krita has tools for each step.

See what is there

Layers can be addressed by id, by Group/Sub/Layer path or by name.

Clean up in one call

recipe_clean_layers(dry_run=True)   # report what would change
recipe_clean_layers()               # do it; one undo step

The recipe deletes empty layers and groups, renames default-named layers after their content (colour, kind and position, for example red shape top-left), trims whitespace and de-duplicates names. unwrap_single_child_groups=true also removes groups that hold a single layer, and case="snake" or "title" normalises the names.

A red ellipse top-left and a blue stroke at the bottom
From the live test: five Paint Layer N layers and an empty group. After the recipe, the empty layers and the group were gone and Paint Layer 1 was named red shape top-left.

Batch rename and organise

Check before export

validate_document(profile="game_sprite", require_power_of_two=True)

It reports empty layers and groups, default names, hidden or 0%-opacity layers, content outside the canvas, duplicate names (which collide in per-layer exports), and colour-space, resolution and size checks for the profile (general, game_sprite, print, web).

Per-layer and per-group PNGs

export_layers(directory="D:/game/parts", scope="groups",
              name_template="{index:02d}_{name}", trim=True)

scope is top, groups, leaves or all, or pass layers=[...]. Each layer or group is rendered on its own (groups composited). With trim, each file is cropped to its content and the result lists the offsets, which is what you need to reassemble parts in an engine.

Sprite sheets with JSON

If each animation is a group of frame layers, one call exports them all:

recipe_group_sprite_sheets(directory="D:/game/sprites", gif=True, scale=4)
Idle sheet, three frames
Run sheet, four frames
idle.png and run.png from the live test, each with a JSON of frame rects and durations and a GIF. Frames are trimmed to a common box, so they stay aligned.

For a single sheet, export_sprite_sheet takes frames from the timeline (source="frames"), from layers (source="layers", bottom first) or from groups, with columns, padding, spacing, trim and an integer upscale. The JSON is in the Aseprite/Phaser "hash" style.

Icon sizes, GIFs, other formats

Undo

Every modifying command, including a whole clean-up recipe, is one step in the MCP undo journal: undo reverts it exactly, redo replays it. get_history lists the steps. The journal is separate from Krita's Ctrl+Z, so ask the AI to undo rather than pressing Ctrl+Z in between.

Get MCP Pro for Krita
$15 once on itch.io, free updates.

itch.io · $15

More guides