Search code examples
gimppython-fu

How do I set properties for different icon layers using file_ico_save in Python-Fu?


I'm using the following code to successfully create an icon with Python-Fu in GIMP:

pdb.gimp_palette_set_background('green')
image = pdb.gimp_image_new(256, 256, RGB)
image.new_layer(pos=1, fill_mode = BACKGROUND_FILL)
fileName = 'C:\\favicon.ico'
pdb.file_ico_save(image, None, fileName, fileName)
pdb.gimp_image_delete(image)

When I export an image as .ico manually, I can set different properties like compression, bpp, alpha-bits, color palette etc. Per default, the largest layer will be saved using compression, which is not recommended. Manually, I can uncheck compression. But saving an icon programmatically with pdb.file_ico_save does not offer those settings.

So how can I set different properties of the icon layers, when saving the icon with pdb.file_ico_save?


Solution

  • To judge from what I think is the source code: https://gitlab.gnome.org/GNOME/gimp/-/blob/gimp-2-10/plug-ins/file-ico/ico-save.c uou can't control those parameters. It looks like the code tries to make intelligent guesses as to the correct values to use, for example compression if the width|height is greater than 255