Skip to content

Instantly share code, notes, and snippets.

@lonequantum
Created September 22, 2021 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lonequantum/795bff7624de585335ac472e356236bf to your computer and use it in GitHub Desktop.
Save lonequantum/795bff7624de585335ac472e356236bf to your computer and use it in GitHub Desktop.
Saves XCF layers to PNG files
#!/bin/sh
# Requires gimp and gimp-python
convert_xcf_to_pngs() {
infile=$1
outfiles_dir=$2
{
cat <<END
def convert(infile, outfiles_dir):
img = pdb.gimp_file_load(infile, infile)
for layer in img.layers:
outfile = outfiles_dir + "/" + layer.name + ".png"
print(layer.name)
pdb.gimp_file_save(img, layer, outfile, outfile)
pdb.gimp_image_delete(img)
END
echo "convert(\"$infile\", \"$outfiles_dir\")"
echo "pdb.gimp_quit(1)"
} | gimp -i --batch-interpreter=python-fu-eval -b -
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment