3

I know how to Invert Colors but is it possible to swap Colors? For example from this one:

enter image description here

To this one:

enter image description here

So that I select one Area and then swap Colors (or even the full Layer/Picture)? By the way I am using Gimp 2.8.10

-Edit: I found this https://superuser.com/questions/155143/how-can-i-swap-colors-with-gimp but this is just for one Color and didnt work for me with the different color tones of transparency and it just works with one color at a time, where I need both colors swapped.

  • Could you please explain the downvote? – levanth Sep 18 '14 at 8:05
  • 1
    Question shows no effort. If you hover your mouse over the down arrow, you can see why down votes happen. – Scott Sep 18 '14 at 8:18
  • @Scott, I didn't know that. – Rosenthal Sep 18 '14 at 21:13
  • 1
    Your goal is a bit unclear. Do you want to swap the colors on a true color image or on a paletted one? In this case you can simply edit the palette, it's a very quick operation. – Paolo Gibellini Sep 19 '14 at 21:31
  • I need to swap the two colors in a selected area – levanth Sep 19 '14 at 21:33
2

There is a filter in Photoshop called Selective Color that allows the user to modify multiple colors at the same time, but until 9/18/2014 nothing similar has been implemented in Gimp. The closest tool in Gimp to deal with what you are looking for is the Channel Mixer.

4

If you have more than a few, but less than 256 colors, you can work in indexed mode and reverse the ordering of the colors.

This can be done in 3 steps:

  1. duplicate and store palette
  2. reverse ordering of colormap
  3. apply the stored palette

Here a detailed explanation of these 3 steps:

  1. Palettes dialog (Windows -> Dockable dialogs -> Palettes): right click on the current colormap, select "Duplicate Palette", choose a new name (e.g. original palette), and save it.
  2. Rearrange Colormap (Colors -> Map -> Rearrange Colormap): right click, then click on "Reverse order", click ok.
  3. Set Colormap (Colors -> Map -> Set Colormap): click on the Palette and select the palette saved in step 1, click ok.
  • For anyone who runs into the same problem as I did: GIMP opened the palette chooser in the background (in step 3). That's why I got stuck at first, but in the end it worked out fine. – twigmac Feb 9 '18 at 9:57
1

In such a simple image, not very difficult. The basic principle is that the text is made of pixels of varying intensity (fully opaque for most, but partially opaque on the edges) overlaying a background. So what we need to do is to recover that opacity, and use it when repainting with new colors. Note that this technique works to change foreground/background to any color, bot just exchange them.

So, starting with:

Initial

We use Colors>Color to alpha to remove the background color. The remaining pixels have exactly the opacity necessary to recreate the text:

after color-to-alpha

We can then paint with the same opacity by setting the alpha-lock on the layer. The alpha-lock is the checkerboard icon in the "lock" line at the top of the Layers list. When it is set, the opacity of the pixels cannot change. So we can bucket fill the whole layer with the new color, the color will only "stick" on the opaque pixels (and stick partially on the partially opaque pixels):

after bucket fill with alpha-lock

To fill the background, we could just add a layer filled with the new background color, move it to the bottom of the stack and merge everything, but there is a faster method: use the Behind mode of the bucket-fill tool (the "mode" is the selector at the top of the Tool options). In that mode, paint tools only fill transparent pixels, partially fill partially opaque pixels to "complement to opacity" with the new color, and leave alone the opaque pixels. As the name implies, it is equivalent to painting on a layer behind the selected layer, so after resetting the alpha-lock (because this time we change the opacity of pixels), just bucket-fill the whole layer with the new background color:

enter image description here

The images at their actual size:

enter image description here

0

If the image has few pixels as this one, and would not suffer loss on being changed to indexed (max. 256 colors), you can edit an image color map directly. That way you could just select the pixels in the color you want to replace, and type a new value for them.

Change the image to indexed in image->mode->indexed, and them open the colormap dialog in windows->dockable dialogs->colormap. Double click on an indexed color to change it.

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.