gimp_file_save(): to lossy file saves size of largest layer, not size of image
When you crop an image now, the layer remains the original size of the image, but the image size (and layer offsets) are changed by the crop. If you then call gimp-file-save from a plug-in, you get the original image, not the cropped image.
To reproduce in 2.10:
- open an image
- Crop it to some smaller size
- Filters > Python-fu > Console, and type:
>>> img = gimp.image_list()[0]
>>> l = img.layers[0]
>>> l
<gimp.Layer 'dsc04394.jpg'>
>>> img.width, img.height
(1000, 1000)
>>> l.width, l.height
(6000, 4000)
>>> pdb.gimp_file_save(img, l, "/tmp/foo.jpg", "/tmp/foo.jpg")
Now outside of GIMP, check the size of /tmp/foo.jpg : it will be the original image size (6000x4000 in this case), not the image size (1000x1000).
This breaks any plug-ins that use gimp-file-save on images that might have been cropped, and seems generally unintuitive. Jehan agreed that gimp-file-save should use the size of the image, not the layer, and that using the layer size sounded like a bug.
Happens if you save to png as well as jpg, so it's not specific to the jpeg file plug-in. I haven't checked in 2.99 yet (gimp.image_list() doesn't work any more, so it at least needs a different set of python-fu commands).