Gimp-Forum.net
anyway to automate applying a custom pallet to an image? - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP)
+--- Thread: anyway to automate applying a custom pallet to an image? (/Thread-anyway-to-automate-applying-a-custom-pallet-to-an-image)



anyway to automate applying a custom pallet to an image? - gimpuser2000 - 08-29-2023

I have thousands of images to process. I would like to apply a custom palette to each. 

So Alt-I > M > I brings me to the custom palette menu

all that's easy to automate with a mouse macro even

but the rest isn't easily automated. i want to apply the "Grays" default palette to the image

and then i have to scroll down and use the search to find "Grays". it will always be the "Grays" palette.

then click convert

I would like a one button solution. 

1. load the image
2. click a button to apply the "Grays" palette < this is the part i want to automate
3. do my edits to the image
4. save it

can this be done with python maybe?


RE: anyway to automate applying a custom pallet to an image? - Ofnuts - 08-29-2023

In Image > Mode > Indexed if you set and select the custom palette, the custom palette option and the selected palette remains for further uses, so you only look up the palette once per Gimp session.

Also you can speed up the retrieval of the palette because the line next to the palette thumbnail can be used to enter the beginning of the name:

[attachment=10281]

Unfortunately, if you can set "Use custom palette" as a default, you cannot change the default custom palette, and looking at the source code it seem that the "Web" palette has a special status, so replacing that palette by a grayscale palette may not work.

Making a script to do the indexation is trivial, but one would need to know the other options that you use (dithering, etc..).

Otherwise why are you converting to indexed with Grays, instead of just de-saturating the image, or converting to grayscale? Indexed mode is ripe with restrictions. And unless you are editing PNGs you have to enter a new extension when saving. I says this because when you have thousands of images to process, I have a script that, with a single keystroke,
  • save the current image (under the same name)
  • closes it
  • opens the next image in sequence in the directory
so this potentially spares you two visits to the file dialog per image, including one where you have to hunt down the next file. This is a great time saver...


RE: anyway to automate applying a custom pallet to an image? - gimpuser2000 - 08-29-2023

a solution that someone posted worked out for me

Select the palette. In my case "Grays"
keyboard shortcuts and search for 'palette map' assign to a key.
load the image
press the assigned key


RE: anyway to automate applying a custom pallet to an image? - Ofnuts - 08-30-2023

(08-29-2023, 08:46 PM)gimpuser2000 Wrote: a solution that someone posted worked out for me

Select the palette. In my case "Grays"
keyboard shortcuts and search for 'palette map' assign to a key.
load the image
press the assigned key

Still not sure why you want to use this method to make a grayscale picture. This degrade the quality, compared to Colors > Desaturate > Desaturate (32 levels of grays instead of 256).

And my suggestion to skip the file dialogs still holds.