2

In Gimp I have a simple graphic image with two colors (a foreground and background color) with anti-aliasing between them. I would like to change either one or both of the colors in the image to another arbitrary color.

This would be easy (I could simply use the paint bucket tool, color select, etc.) except that I want to preserve the anti-aliasing that's already in the image. I don't want to just replace exactly one color with exactly one other because then I would get a weird stripe or jagged edge where the colors meet.

Any suggestions? Thanks.

2

Depending upon the colors and how good the original anti-aliasing is, you may get away with simply using Colors > Map > Rotate Colors..

But to do it more accurately, use Color-to-Alpha to separate the foreground and background into two layers, thus:

  • Layer > Transparency > Add Alpha Channel
  • Layer > Transparency > Color to Alpha... (use color-picker to pick background color)
    (This should remove the solid background completely but leave the anti-aliasing pixels with opacities proportional to their mix of background/foreground color)
  • add new layer, initialise to new background color and move below foreground layer
  • select foreground layer and use Colors > Colorise to set the new foreground color (including the partially-transparent anti-aliasing pixels)

Alternatively, you could use bucket-fill to set the new foreground color thus:

  • (Layers Dialog) Alpha to Selection
  • (Layers Dialog) Lock alpha channel (small button above layers list)
  • bucket-fill the whole selection
0

For anyone else with this issue, I messed around and found a solution that worked for me. If the colors are very different, Colors > Color to Alpha can be good, but if the colors are similar, like Blue on Green, then setting the green to alpha will make the blue partially transparent as well.

Instead:

  • If it isn't already, convert the image to be "black and white" (with some gray for anti-aliasing, soft edges, or other gradients). Do this by completely desaturating the image or converting it to grayscale to remove the colors, then upping the contrast a bit and using the bucket fill tool with a very low threshold to get the main patches of image to be really black and white, not just dark gray and light gray.
  • Then, select the two colors you would like to use to be your 'forground' and 'background' colors in your color palette.
  • Then, simply click Colors > Map > Gradient Map.

It should swap the colors just the way you would expect.

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.