Score:0

Gimp: Exporting each layer as separate image BUT keep original file name

st flag

Variations of this question have been asked, so hopefully I can get some help.

I open as Layers several dozen images at a time. I am doing this so I can crop them all at once to a certain size.

Now I need to export each layer as a separate image file. As identified in another question, the "long way" is to manually export each layer while keeping the other ones invisible. Then one by one I tediously repeat this step. What makes this longer is that each separate layer already has the correct file name but when exporting I have to manually type in the file name again.

By exporting as an .ora I can have all layers saved as separate images however when unpacking the .ora file they are renamed. It is slightly faster than exporting layer one by one but manually renaming each file but without the knowledge of which is which it actually takes longer if not completely unviable.

The file names are very important, they are four parts divided by "-" character. Getting them named in the first place is a headache. Now im repeating the process after I crop them in GIMP!

I am usually doing 600 images per project with endless projects on the horizon. Even if I can get 2 images saved per minute that's still 5 hours extra im my workflow, of which cropping and now renaming is one of the very last steps. Many of the scripts and plugin solutions are obsolete and have support dropped. And none of them solve my renaming dilemma.

Is there a way for GIMP to export each layer as a separate image AND keep the filename each layer has already???

vanadium avatar
cn flag
That would make for a valid feature request. In the mean time, you could consider using batch tools like imagemagick convert for mass processing images.
Score:1
om flag

See the ofn-export-layers script(*). You can use a format pattern to generate the name on export. One of the available name parts is the layer name, with any file extension removed.

PS: Since this is Ubuntu: the script requires Python support, and this is not available in the Gimp version from the Ubuntu repos since 20.04. There are ways to retrofit it, or you can install the flatpak version, that comes with its built-in Python interpreter.

(*) Installation instructions at the bottom of the linked page, and the ZIP file contains a HTML doc that explains the name pattern.

Paperclip Bob avatar
th flag
Very useful plugin! Although I had one problem which I eventually worked around: I started out with layer name "ABC.jpg", then duplicated the layer twice. The layer names become "ABC.jpg copy #1" and "ABC.jpg copy #2". Your script seems to lop off everything after the '.' from the layer name. But, since the sequence number of my layers (copy #1, copy #2, etc.) appears *after* the '.', the sequence numbers are lost. In this case all I ended up with was ONE single file named "ABC.png" which (confirmed by testing) gets overwritten by each layer.
xenoid avatar
om flag
@PaperclipBob Good catch. Will fix!
xenoid avatar
om flag
@PaperclipBob Script fixed...
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.