python: Fix crash when exporting indexed ORA images

Exporting ORA images involves first creating PNGs of
the layers. To do this, we create separate images for
each layer with Gimp.Image.new ().
However, if the original image was indexed, we lose
the palette when passing the temporary image to
the PDB call. This caused us to try saving a NULL
palette, which resulted in the crash.

This patch adds a check if the image is indexed, and
copies over the palette to the temporary image.
This commit is contained in:
Alx Sa 2025-03-15 02:36:20 +00:00
parent a091b6b2d8
commit 4cd3360d53

View file

@ -218,6 +218,9 @@ def export_ora(procedure, run_mode, image, file, options, metadata, config, data
width, height = drawable.get_width(), drawable.get_height()
tmp_img = Gimp.Image.new(width, height, image.get_base_type())
if (image.get_base_type() == Gimp.ImageBaseType.INDEXED):
tmp_img.set_palette(image.get_palette())
tmp_layer = Gimp.Layer.new_from_drawable (drawable, tmp_img)
tmp_img.insert_layer (tmp_layer, None, 0)