0

I have a batch processing script in GIMP that, for every image file in a directory, involves importing the image, importing a background image as a layer, doing some edits, and exporting the image. The edits take no time at all but the gimp-file-load, gimp-file-load-layer, and gimp-file-save steps take a combined total of 3-4 seconds for a 69x96 .tga image and so the batch process will take the better part of a day to handle thousands of files.

Is there a faster way to import/export these images GIMP? Maybe I can eliminate the background import step by keeping the background image open until the batch process is complete. But then what would I use in place of

(gimp-file-load-layer 1 image background)

to add the background image as a layer? I don't know of any procedures that can transfer data between two images, open in GIMP or not, without using clipboard (which I'm already using to transfer alpha channel data) or file-load.

  • I have a very hard time believing your numbers... or at least believing that the problem is with Gimp. You likely have some I/O contention somewhere. Where a the files? SSD? HDD? external disk? network? Also, what kind of edits are you doing in Gimp that you cannot do with ImageMagick? – xenoid Nov 01 '21 at 22:11
  • All files are on my SSD. I linked to my script so you can see the exact procedures I'm calling. I've run them all individually in the script-fu console and they're all instantaneous except the file-load and file-save procedures which take just as long individually as they do in the batch script. I'm not the only one who has [reported](https://www.gimpusers.com/forums/gimp-user/20613-gimp-2-10-very-slow) [slow](https://www.reddit.com/r/GIMP/comments/bj15i0/gimp_210_is_extremely_slow_on_certain_operations/) [import/export](https://gitlab.gnome.org/GNOME/gimp/-/issues/5705) in GIMP 2.10. – Callistonian Nov 01 '21 at 23:57

1 Answers1

0

Not really an answer but too long for a comment:

Using two 200x200 TGA files (filled with plasma):

import time
times=[]
times.append(time.time())

image = pdb.gimp_file_load("/tmp/TGA/TGA-200x200-in.tga","/tmp/TGA/TGA-200x200-in.tga")

times.append(time.time())
layer = pdb.gimp_file_load_layer(image, "/tmp/TGA/TGA-200x200-in2.tga")

times.append(time.time())
pdb.gimp_image_add_layer(image, layer, 0)

times.append(time.time())
layerOut = pdb.gimp_image_flatten(image)

times.append(time.time())
pdb.file_tga_save(image,layerOut,"/tmp/TGA/TGA-200x200-out.tga","/tmp/TGA/TGA-200x200-out.tga", 1, 0)

times.append(time.time())

print "Steps:", [ "%5.1fms" % ((e-s)*1000) for s,e in zip(times[:-1],times[1:])]
print "Total: %5.1fms" % ((times[-1]-times[0])*1000)

Yields:

Steps: [' 97.7ms', '106.3ms', ' 20.6ms', ' 22.2ms', '102.6ms']
Total: 349.4ms

So this is 10 times faster for me. Tried variations (using file-save instead of file-tga-save for instance) without any significant changes in running time.

Yes, this is Python but AFAIK this ends up running the same code in Gimp (otherwise you have a solution...). So IMHO you have an I/O bottleneck.

Measurements on Core i5-9400H 2.50GHz with SSD, running Linux and an ext4 file system (which could be another solution...).

xenoid
  • 8,396
  • 3
  • 23
  • 49