gimp_file_save(): specifying a run_mode produces mostly incorrect results
Environment/Versions
- GIMP version: 2.10.32
- Package: <Self-compiled
- Operating System: Linux
Description of the bug
When one specifies a run_mode
keyword parameter in pdb.gimp_file_save()
in python-fu, the results are mostly incorrect: the doc specifies that a layer is saved (which is indeed what happens when there is no run_mode
or when it is set to RUN_NONINTERACTIVE
but other run_mode values make the whole image to be saved.
Reproduction
Is the bug reproducible? yes Reproduction steps:
- Create an image with two layers:
- Run this code in the Python console (possibly adjust directory names):
image=gimp.image_list()[0]
for type in ['png','jpg','webp','tif','bmp','tga','gif']:
print "Exporting %s" % type
for mode in ['RUN_NONINTERACTIVE','RUN_INTERACTIVE', 'RUN_WITH_LAST_VALS']:
file='/tmp/test/Layer-%s.%s' % (mode,type)
try:
pdb.gimp_file_save(image,image.layers[0],file,file,run_mode=globals()[mode])
except Exception as e:
print 'Dies for "%s" with %s: %s' % (type,mode,e.args[0])
Expected result:
- All exported images show a single layer
Actual result:
Where one can observe:
With no run mode:
- OK for BMP, PNG, TGA., WEBP
- No GIF output ("Cannot export RGB color images. Convert to indexed color or grayscale first.", but then it can in the UI?)
- TIF output is the wrong layer, (not the layer specified in the call, and not the active layer)
- JPG output is filled with black (the test was run with the usual Black/White as FG/BG so one would have expected a white fill...)
For RUN_NONINTERACTIVE
:
- same as with no run mode
For RUN_INTERACTIVE
:
- Most types produces a full image (including GIF)
- TIF outputs the wrong layer
- JPEG correctly fills with white
For RUN_WITH_LAST_VALS
:
- same as with
RUN_INTERACTIVE
Additional information
When exporting individual layers from an image, it is useful to export the first with RUN_INTERACTIVE to capture the user's needs and then export the rest of the layers with RUN_WITH_LAST VALS
. If some design decision makes the code export the whole image, then it should be documented as such and the TIF export should be fixed to comply.
Trying the same test on a 2.8 version shows essentially the same problems, but TIF output is similar to the others, only LAYER-1
for the first two and a full image for the last two.