Krita Random Exporter

Python script for exporting big batches of random layer combinations from Krita, with rarity and optional GIFs.

GitHub Repo

Overview

Python script for exporting large batches of random images from Krita by turning trait layers on and off. It handles weighted traits, rarity, unique combinations, JSON metadata and optional animated GIFs.

It's basically the scaffolding from a script I used in 2021 to generate a bunch of random images and gifs, so it's meant as a starting point to modify, not something to run as is.

Setup

Edit the attributes and rarity_counts at the top of randomMassExporter.py, then run it through Krita's built-in Scripter plugin with the source document open. Trait layers need names like traitName_variationName, and they can be inside groups.

Animation export

Set up the animation timeline in Krita, leave generate_animation on, and set ffmpeg_path if FFmpeg isn't on your PATH.

Included Features

Layer Combinations

Turns named trait layers on and off for each image, including layers inside groups.

Weighted Traits

Each normal variation has a weight that sets how often it shows up.

Rarity Groups

Set how many images each rarity gets, with rare variations more likely at higher rarities.

Unique Results

No duplicate combinations, and it stops with an error if it runs out.

JSON Metadata

Saves each image's traits and rarity to a JSON file.

Animation Export

Optional animated GIFs through FFmpeg.