3

In GIMP, when converting the color mode of an image into indexed, you are presented with the following dialog:

indexed_mode_dialog

When you let GIMP create the palette for you, you are able to specify the maximum number of colors. However when you use a custom palette, there seems to be no equivalent option for limiting the number of colors used.

What are some ways to work around this?

I want GIMP to calculate the closest colors among those in my custom palette so manually trimming the palette is not ideal.

  • Could you perhaps convert to your custom palette, then convert back to RGB mode, then convert to Indexed again, and choose the Optimum palette option, and then reduce the number of colours? – Billy Kerr Dec 1 '17 at 8:25
  • Basing upon the GIMP documentation you can check the 'Remove unused colors from final palette' option. If your custom palette is composed by e.g. 120 colors, the colors should be limited to 120. – Paolo Gibellini Dec 1 '17 at 8:37
  • @BillyKerr This doesn't work because Gimp will create colors that aren't in the initial palette. – xenoid Dec 1 '17 at 9:24
  • 1
    So, the opposite of what others suggest, 1) convert to indexed with optimum palette but restrict the number of colors, and 2) convert back to RGB, and then convert to indexed with your palette, to coerce the colors to your palette. This ensure that the final colors are in your palette. – xenoid Dec 1 '17 at 9:29
  • @xenoid - you're right. I had it backwards! You should post that as an answer. I'd upvote it. – Billy Kerr Dec 1 '17 at 10:12
2
  1. convert to indexed with optimum palette but restrict the number of colors to the number you want
  2. convert back to full RGB
  3. convert again to indexed with your palette, to coerce the colors to your palette. This ensure that the final colors are in your palette.

This however assumes that your palette has a range of colors somehow compatible with the initial image.

  • I tried your idea, but sadly it doesn't work. When you convert it again to indexed (step 3), GIMP does not produce a new palette of the same restricted size. Instead it creates a new palette with a maximum size of the custom palette size. (For example, lets say I restrict it to 8 colors and index it with the optimum palette. When re-indexing it with my custom palette of 64 colors, the new indexed image has more than 8 colors.) – Jet Blue Dec 2 '17 at 7:27
  • Indeed. Rather unexpected. Similarly, Colors>Posterize has more colors than requested. – xenoid Dec 2 '17 at 9:42
  • 1
    Hmm. Are you using dithering on the second indexation? – xenoid Dec 2 '17 at 15:31
  • Ah, that's exactly the problem, I was dithering on the second pass. Thank you! – Jet Blue Dec 4 '17 at 0:43
  • I needed a 2 color dither interpretation of 1 color from a reduced palette, but this method resulted in a single color from that palette, which I'm sure would be better represented with two. So *reversing your method I achieved a slightly better result. 1. index to my palette with dithering. 2 convert back to full rgb. 3 re index to 2 color index (without dither) 4. back to rgb 5 re index finally back to my palette (without dither). – Mr Purple Apr 7 '18 at 23:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.