Gimp: Export every layer as a separate PNG image

172,226

Solution 1

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.

Solution 2

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 ...

    myfile.ora

  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
    

    alternatively

    $ unzip myfile.ora
    

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

Solution 3

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

Solution 4

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.

Solution 5

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

Features:

  • 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.
Share:
172,226

Related videos on Youtube

Parto
Author by

Parto

Far better it is to dare mighty things, to win glorious triumphs, even though checkered by failure, than to take rank with those poor spirits who neither enjoy much nor suffer much, because they live in the gray twilight that knows neither victory nor defeat. ― Theodore Roosevelt

Updated on September 18, 2022

Comments

  • Parto
    Parto 3 months

    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.

    • Jeff Puckett
      Jeff Puckett about 3 years
      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.
  • Parto
    Parto over 8 years
    This was the easiest. Extract the file, copy the .py file to your ~/.gimp-2.8/plug-ins folder, make it executable, restart GIMP.
  • installero
    installero over 8 years
    Doesn't work in GIMP 2.6 btw.
  • moi
    moi over 6 years
    This is also availabe at GitHub: github.com/khalim19/gimp-plugin-export-layers
  • LowFieldTheory
    LowFieldTheory about 6 years
    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.
  • Petah
    Petah about 6 years
    This exported a flattened image for me :(
  • VIK
    VIK over 5 years
    Excellent way to do this! Thanks. Works fine in Gimp 2.8.20.
  • GhitaB
    GhitaB over 5 years
    The best. You saved my day.
  • Deleplace
    Deleplace over 5 years
    Very nice. Note that numbering starts with top layers, while some other techniques would start with bottom layers.
  • clickbait
    clickbait over 4 years
    (+1) Cool answer!
  • ether_joe
    ether_joe over 4 years
    the installation instructions for this plugin are stupid. :P Just install please, I don't care about directories.
  • user272901 over 4 years
    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/
  • Job
    Job over 4 years
    The link no longer works, but searching for the plugin name turned up: khalim19.github.io/gimp-plugin-export-layers Is that the plugin you were referring to?
  • Akshay Vijay Jain
    Akshay Vijay Jain about 4 years
    use the link provided by job
  • Skippy le Grand Gourou
    Skippy le Grand Gourou about 4 years
    Furthermore, for large images convert takes ages while unziping an ORA file is almost instant. Good idea, though.
  • Murshid Ahmed
    Murshid Ahmed over 3 years
    If you only wanted specific layers, then this is the better way to go...
  • spacer GIF
    spacer GIF over 3 years
    Looks like ORA support was dropped in 2.10. :(
  • ThorSummoner
    ThorSummoner over 3 years
    @spacerGIF can you cite the removal? Your sure your not mixing up save vs export either right?
  • spacer GIF
    spacer GIF over 3 years
    @ThorSummoner Couldn't find any references to this online, but in 2.8 I used this technique many times and in 2.10 I no longer can. Yes, I am in the Export menu, not Save.
  • Michael
    Michael over 3 years
    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
  • ThorSummoner
    ThorSummoner over 3 years
    @michael yikes, I'd guess the metadata is there in the ora somewhere, might be easy thing to script, at that rate I'm not sure why or what it takes to write a gimp export extension to do the right thing the first place
  • ThorSummoner
    ThorSummoner over 2 years
    I noticed that recent Ubuntu distributions, file-roller might not be happy about opening an ora file, if this is troubling you, adding a .zip to the end of the file name may help convice your given ziptools to extract it
  • Saren Tasciyan
    Saren Tasciyan over 2 years
    Another issue is that the image sizes are now limited to layer sizes. e.g. if you have a layers, which has transparent boundaries, then exported image of that layer is smaller than the image itself.
  • ThorSummoner
    ThorSummoner over 2 years
    @Genom good call out, as a work around, does resizing each layer to match the image size help in this case?
  • FeRD
    FeRD over 2 years
    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
    FeRD over 2 years
    (In fact, as GIMP is exporting the ORA file, you can even see it dumping all of the layers into a temp directory AS INDIVIDUAL PNG FILES before it proceeds to zip them all up. If we could halt that export process one step sooner, we'd be done already.) 😎
  • FeRD
    FeRD over 2 years
    So, turns out the exporter for ORA files is written in Python. See my answer for why that matters.
  • FeRD
    FeRD over 2 years
    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.
  • deepthought-64
    deepthought-64 almost 2 years
    Works very nice! Thanks!
  • ernstkl
    ernstkl almost 2 years
    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)
  • FeRD
    FeRD almost 2 years
    @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.)
  • rautamiekka over 1 year
    ORA export works perfectly fine in 2.10.26 (at least on Window$). It's very slow, but it works. gitlab.gnome.org/…
  • pipe
    pipe 10 months
    This worked well for me, but there are issues with transparency. I did not need it in my project but I don't think it will work if you need to preserve the layer transparency/alpha mask.
  • brunetton
    brunetton 9 months
    This doesn't answer to the question "I want to export every single layer as an individual image (PNG format preferably) automatically" as this method is not automated