Skip to content

Instantly share code, notes, and snippets.

@agateau
Last active August 29, 2015 14:07
Show Gist options
  • Save agateau/8e4e035b66c520f85077 to your computer and use it in GitHub Desktop.
Save agateau/8e4e035b66c520f85077 to your computer and use it in GitHub Desktop.
Save GIMP layers as individual png files
#!/usr/bin/python
"""
Saves all visible layers of an image as individual png files in the same
folder as the image, using <layer-name>.png for the name.
To use it:
- Save this file in ~/.gimp-$version/plug-ins/
- Restart GIMP
- Open the Image menu, select "Save Layers"
Based on instructions from http://stackoverflow.com/questions/20522304/gimp-save-all-layers-to-files-with-the-layers-size
"""
import os
from gimpfu import *
def plugin_main(timg, tdrawable):
folder = os.path.dirname(timg.filename)
for layer in timg.layers:
if not layer.visible:
continue
name = os.path.join(folder, layer.name + '.png')
pdb.gimp_file_save(timg, layer, name, name)
register(
"python_fu_save_layers",
"Save layers as individual images",
"Save layers as individual images",
"Aurelien Gateau",
"Aurelien Gateau",
"2014",
"<Image>/Image/Save Layers...",
"RGB*, GRAY*",
[],
[],
plugin_main)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment