Need some script fu

Hi,

I would like to find a way to batch process all the jpeg’s in a directory, this process being: load the jpeg > apply wavelet decompose plugin > save as .xcf to keep all the layers.
Any idea how to do that?
I found how to call the plugin (using BIMP), but I don’t know how to save the .xcf image with all layers un-flattened.

If you save to XCF the image won’t be flattened?

xcf is The Gimp’s native format
and it preserves the layers.

Have fun!
Claes in Lund, Sweden

Salut @sguyader,

This might be a good start?

Cordialement,
Claes en Lund, La Suède

Maybe… When I use a script and save to xcf an image with several layers, I can only save the base layer. But I don’t really understand the drawable/layer stuff in scripts.

Salut,
It looks promising, though I’m not sure if it saves all layers. I’ll give it a try.

Unfortunately, it’s not good: it saves as many files as there are layers in the opened file, though each saved file has all the layers. In other words, if a file has 3 layers, the plugin creates 3 copies of the file with 3 layers in each.

Did you really try or did you get abused by the fact that the API takes a drawable(*)? I think that parameter is here only to make the XCF case similar to the “flat” formats, and when I use that API it saves all the layers (as well as selection, channels, and paths).

(*) Note that in other file-*-save functions, the drawable is described as “The drawable to save”, but the description in file-xcf-save is different.

I did try. But not too hard, I tried to adapt existing scripts I found, but I don’t understand the syntax deeply yet.

Salut!

Sorry about bad advice yesterday :frowning:
I blame the fact that it is more than 20 years since I script-fu’d last time.

a) Of course it ought to be possible to script what you are after!

b) On this particular computer I have The Gimp 2.99.1 installed.
Shortcut / takes you to Search and Run a command, where Save a copy
exists. Are you able to tame Gimp commands? If so, that could be a way out of your dilemma.

Cordialement,
Claes en Lund, La Suède

Hello,
I found this command in Gimp 2.10. I’ll see if I can manage to call it in batch command line mode after wavelet decompose…
But if I lose too much time searching for a solution, it’s not worth it as I was trying to find a script to lose less time…

I found the solution!
Using the changes for batch mode in command line introduced since Gimp 2.10, here’s a command to apply the wavelet-decompose plugin, and save the images untouched with all the layers as .xcf files:

gimp -i -b '(with-files "*.jpg" (plug-in-wavelet-decompose 1 image layer 6 0 1) (gimp-xcf-save 0 image layer (string-append basename ".xcf") (string-append basename ".xcf") ))' -b '(gimp-quit 0)'

the options for wavelet-decompose stand for:
1=non interactive mode,
6=# of scales,
0=no layer group,
1=add layer masks

1 Like

I just had to replace “drawable” with “layer” in the command.

What “changes for batch mode in command line introduced since Gimp 2.10”? This was there in 2.8 too… (and in 2.6 IIRC).

I think it is about the with-files "*.jpg" part.
https://wiki.gimp.org/wiki/Release:2.10_changelog#Batch_processing

Ah… Nothing one couldn’t write by himself in the previous versions.