Switch to full style
Post all Gimp scripts and script writing questions here
Post a reply

Performance of adjusting layers and exporting with Python Fu

Sat Jan 30, 2021 1:24 pm

I've written some Python Fu and I am running GIMP from the command line in background mode. My script opens a PSD, changes the fill color of some solid fill layers, pastes an image into a new layer, and then exports a new composite. All this takes around 8 seconds or so on a beefy Windows gaming laptop using the latest stable GIMP 2.10.22. Maybe half that if I don't paste a new image layer in. This really is fantastic -- I don't know of any other open source tools that could do this so well. But I would love to be able to speed it up 10x. Any thoughts on performance?

Re: Performance of adjusting layers and exporting with Python Fu

Sat Jan 30, 2021 3:21 pm

Gimp is 'ram dependent' but you are not dealing with image sizes of thousands of layers so it's not an issue. Looks like the process is slow because it's sequential.

Other than optimizing your code (I can't help there) using Gimp in OpenCL mode rather than CPU mode would speed up everything. I don't think OCL is fully implemented in Gimp yet. OCL uses graphics cards (GPU's) to process graphics operations which is a lot faster, especially with more than 1 graphics cards.

Re: Performance of adjusting layers and exporting with Python Fu

Sun Jan 31, 2021 1:33 pm

If you're not doing anything with text, make sure your command line includes the -f option to not load fonts.
Similarly the -d to not load brushes, patterns gradients etc might save you some time.

Re: Performance of adjusting layers and exporting with Python Fu

Mon Feb 01, 2021 11:28 am

paynekj wrote:If you're not doing anything with text, make sure your command line includes the -f option to not load fonts.
Similarly the -d to not load brushes, patterns gradients etc might save you some time.


Thank you I am already doing that with "-ifds" although in the future I will need to be able to use the patterns feature.

Re: Performance of adjusting layers and exporting with Python Fu

Thu Feb 04, 2021 5:50 am

If you start an "empty" Gimp instance then you avoid loading the Gimp code each time.

Alternately, if you want to process several files, you can also provide them as a list (or pass a directory) to a script that will process each in turn. This also avoid reloading Gimp each time.

Re: Performance of adjusting layers and exporting with Python Fu

Fri Feb 05, 2021 1:43 pm

Thanks I will look into that. I do already have some logging that indicates to me the GIMP startup time is minimal and the time is spent exporting a flattened / composite image.
Post a reply