Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
anyway to automate applying a custom pallet to an image?
#1
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?
Reply
#2
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:

   

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...
Reply
#3
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
Reply
#4
(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.
Reply


Forum Jump: