I have come to a situation where I have an image in Gimp with multiple layers. Now, I want to export every single layer as an individual image (PNG format preferably) automatically to a folder somewhere.

Is this possible?

The long method: Hide all layers except one, crop the section you want, export image. Hide saved layer, unhide another one, crop section, export. Repeat. Kinda cumbersome for an image with about 20 layers.

  • Parto please consider accepting the answer by @ThorSummoner askubuntu.com/a/749561/453746 as it seems to be a much better solution for new people finding this answer today without installing a plugin. Sep 28 '19 at 4:23

If PNG is an acceptable output format, one option is to export it as Open Raster (.ora), an open specification for layered-image files.

  1. Export Image as Open Raster (.ora)

    File -> Export As ...


  2. Open myfile.ora as an archive, with a program like file-roller or 7zip.

    On Ubuntu:

    $ file-roller myfile.ora
    $ # note, later version of file-roller on ubuntu hard-code file suffixes, 
      # and refuse to open ".ora" files, work around by renaming the file to ".zip"
    $ ln -s myfile.ora myfile.ora.zip
    $ file-roller myfile.ora.zip


    $ unzip myfile.ora

    All your layers will be png images under /data, Extract them and use at will.

  • 10
    this was awesome, thanks- I think this is the best solution. Nothing to install and very fast. I just did it with GIMP with a PSD. Oct 11 '16 at 13:11
  • 1
    This exported a flattened image for me :(
    – Petah
    Nov 20 '16 at 21:59
  • 6
    Looks like ORA support was dropped in 2.10. :(
    – spacer GIF
    Aug 1 '19 at 20:10
  • 2
    the only issue i have with this is that it doesn't use my layer names as file name, which means that i have to manually map them
    – Michael
    Aug 24 '19 at 21:15
  • 2
    Not only does this still work great with 2.10.20, but there's even a stack.xml file in the archive that includes all of the layer parameters. A sed pipeline can make quick work of whipping up a set of commands to restore the original layer names: cat stack.xml |sed -e 's/><layer/\n/g;' |sed -E -e 's/.*name="([^"]*)".*src="([^"]*)".*/cp "\2" "\1"/;'
    – FeRD
    Jul 29 '20 at 22:16

You may try also this plugin, Export Layers. I've tested it with png format and it worked. You just select the folder and the format and you get all the layers there, each one in its own file.

  • 2
    This was the easiest. Extract the file, copy the .py file to your ~/.gimp-2.8/plug-ins folder, make it executable, restart GIMP.
    – Parto
    Jun 20 '14 at 12:27
  • Doesn't work in GIMP 2.6 btw.
    – installero
    Sep 6 '14 at 10:44
  • 2
    This is also availabe at GitHub: github.com/khalim19/gimp-plugin-export-layers
    – moi
    Aug 24 '16 at 8:30
  • the installation instructions for this plugin are stupid. :P Just install please, I don't care about directories.
    – ether_joe
    Jul 21 '18 at 18:17
  • Agreed that the installed (for linux) is rough; this is the command I needed to use to make it work with an AppImage GIMP install: ./export_layers-3.2.1-linux.run --target /home/myname/.config/GIMP-AppImage/2.10/plug-ins/ -- -g /path/to/gimp-git-2.10.5-20180719.glibc2.15-x86_64.AppImage -i /home/myname/.config/GIMP-AppImage/2.10/plug-ins/
    – user272901
    Aug 21 '18 at 5:13

First of all you don't need any plugin. Even you don't need to crop anything. Few simple steps.

  1. Select a layer. To do that just click on that particular layer.
  2. Copy the layer to a clipboard using Ctrl+C
  3. Now create new image using Ctrl+Shift+V

That's it. Now you can simply export that layer to any format.

  1. Use Shift+Ctrl+E
  • If you only wanted specific layers, then this is the better way to go... Jul 10 '19 at 18:20
  • 4
    Also, if you only wanted two or three layers. Not so great if you find yourself (as I did yesterday) wanting to export each and every one of the 79 frames in an animated gif.
    – FeRD
    Jul 31 '20 at 21:25

One could export the image as an animated GIF. This will save each layer as a separate frame in the GIF.

Then, the ImageMagick command convert -coalesce ./myfile.gif outfile%05d.png will extract the frames as PNG images.

  • 6
    Note: GIFs only support 256 colour palettes, so it would not be possible to do 24-bit PNGs this way. Mar 24 '16 at 5:34
  • 2
    Furthermore, for large images convert takes ages while unziping an ORA file is almost instant. Good idea, though. Dec 16 '18 at 21:27

Certainly, this work for the plugin Export Layers to File.


  • Manipulate the layers in layer group.
  • Export texts, patterns and layer filters.
  • Prefix name for the image files has to be given.
  • Export only in jpg, png, bmp formats but the required formats can be added easily.

I think you can try to find something with ImageMagick : apt-get install imagemagick. It seems to be able to handle XCF format and you can export a layer in png using a [N] in the command, where N is the level of your layer.

Source : http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=17603

ImageMagick Read Mods : http://www.imagemagick.org/Usage/files/#read_mods


The best thing about ThorSummoner's answer is that it called attention to the OpenRaster export plugin, which as it turns out lives in the file file-openraster.py in the GIMP installation.

By reading its code (and with some assistance from the built-in procedure browser), I was able to determine that the layers of a GIMP XCF can be saved to individual PNGs by going to Filters > Python-fu > Console in the interface, and entering the following into the built-in Python interpreter:

import os

# If you have multiple images open, you may need to adjust
img = gimp.image_list()[0]

savefn = gimp.pdb['file-png-save-defaults']
outpath = "/home/$USER/Pictures" # (or r"C:\Users\$USER\Pictures", etc)

for lay in img.layers:
    # Even if your layer names contain spaces, not a problem
    outname = lay.name + ".png"
    savefn(img, lay, os.path.join(outpath, outname), outname)
    # type an extra newline to exit the indented block

You'll see the progress meter in the image window's status bar start whipping through all of your layers, writing each one to a PNG file of the same name, in whatever directory you specified as outpath. (Which must already exist, otherwise add an os.makedirs(outpath, exist_ok=True) before the loop.)

If any of your layer names are the same, that is a problem, because this will happily overwrite any previously-written files. Caveat GIMPtor.

Edit: If you do have same-named layers, you could easily ignore the names and instead write out the layers in numbered files. Just replace the final loop above with something like:

for n, lay in enumerate(img.layers):
    outname = f"Layer {n:03}.png"
    savefn(img, lay, os.path.join(outpath, outname), outname)

That'll write the layers into PNG files named "Layer 000.png" through "Layer 999.png" (or however many layers are present, if fewer than 1000).

If the Gimp's version of Python doesn't support f-strings (Python 3.6+), this is exactly equivalent:

outname = "Layer {0:03}.png".format(n)
  • 1
    Hilarious, thanks! On windows, I had to add a target path like this, because otherwise it tries to write to c:\windows\system32: savefn(img, lay, 'c:\\temp\\'+outname, outname)
    – ernstkl
    Mar 18 at 15:34
  • 1
    @ernstkl Ah, yeah, that probably makes sense. I'll incorporate a full-path example as well, since launching graphically is surely way more common the running gimp from a terminal like I did. (You can actually write that path without doubling slashes using raw strings (r"C:\temp\"), or as "C:/temp/"+outname since Python has supported separator translation on Windows for a while now. The "most correct" canonical form would probably be os.path.join("C:", r"\temp", outname) but that's pretty ugly. And kind of pointless when the path is entered directly, rather than stored in a variable.)
    – FeRD
    Mar 19 at 20:30

I was doing the same thing and trying to download the plugins mentioned in the answers. As the Gimp website is currently down, I could not get the plugins and I had to find another solution.

What I ended up doing was use the screenshot software Shutter, which allows you to select a region of the screen and then you can repeat the same screenshot of that region with just 1 click. So it becomes a 2-click per layer operation: hide layer, screenshot, hide next layer, screenshot, ...

Much faster than anything else I could come up with, and takes less than a minute for 20 layers. You may lose image quality although in my case it was not a problem.


As an alternative approach to my previous script-based suggestion, I have finally discovered that you can also do this with one of the tools available if you have the GIMP GAP installed. (That's the Gimp Animation... Package? Plugin? Something like that.)

It's a bit hidden in the forest of GAP menu options, but the "Video" menu selection "Split Image to Frames..." will do so by saving each layer as an individual file. In whatever format you specify (via the file extension), and with several options for how to handle the layers. Here's the dialog that came up when I chose that option after saving an un-optimized animated GIF as a 52-layer /tmp/testfile.xcf:

Split Image into Frames dialog window

Despite the filename preview, the frames were saved as /tmp/testfile_01.png through /tmp/testfile_52.png, as specified. (It doesn't update the displayed string in response to your selections, but it does honor them.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.