Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is probably a very easy question, but I am stumped.

I am trying to edit a png. I select a colour with the "Select by color" tool, change the fill colour to red ff0000, or 255,0,0, but when I click the selection to fill, it looks brown.

Other colours also act this way: blue -> purple, yellow -> light brown, etc. White seems to fill correctly.

So, what am I doing wrong? I'm thinking it has to do with the file format or some underlying filter.

share|improve this question
up vote 15 down vote accepted

It sounds like the image you are editing is using a limited colour palette rather than full 24-bit RGB. GIMP is doing its best to do what you ask while using colours in the existing palette.

If you want to switch the image to full colour, select Image -> Mode -> RGB from the menus. You should then be able edit the image using any colours you want.

If you need to save the image with an indexed colour palette, you can switch back again by picking the Indexed... menu item from the same menu. This will pop up a dialog box asking what sort of palette you want to use for the image. The default option should suffice.

If you don't need an indexed colour palette, I would just leave the image as RGB. For many of the images people use PNG files for, the savings are small.

share|improve this answer
1  
I need to preserve the existing size and format. The only things that may change is the colors. If I edit it with full color, and save it as limited, won't that be the same as editing it with the limited palette? I.e. the colors in the savefile will reverse? – TLP Sep 19 '11 at 15:06
2  
If you choose to automatically create a palette when converting back to indexed, you will likely end up with a different colour palette. Depending on what the requirements are for the image, this may or may not be acceptable. Since the image format is compressed, it is unlikely that you'll end up with a file of exactly the same size either way. – James Henstridge Sep 20 '11 at 0:25

As James Henstridge notes, your PNG image is probably in indexed color mode. An indexed color image uses a specific limited color palette, and when editing such an image, GIMP will only use the colors available in the palette, mapping any other colors to the closest one in the palette.

In general, as James suggests, you'll need to convert the image to RGB color mode in order to freely edit it. However, if you just want to replace a particular color with another one, everywhere it occurs in the image, then there's another option: you can edit the color palette itself by using the Colormap dialog.

Just open the dialog (WindowsDockable DialogsColormap), double-click on the color you want to replace, and choose the new color you want in the color picker window that opens up.

The Colormap dialog also allows you to add new colors to the color palette, so that you can then draw using those new colors in the image (by first setting the color you want as the foreground color, and then clicking the + button in the Colormap dialog). This can be useful if you e.g. want to replace only some pixels of a particular color with the new color. However, note that indexed color mode (in GIMP, and also in the PNG format itself) only supports a maximum of 256 colormap entries. If you need more colors than that, you'll have to convert the image to RGB mode anyway.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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