Invert Colors in JPG (I.E. White drawing on color to color on white)

I have a JPG of a logo that is drawn in white on a colored background. I want to invert the logo so the logo is in color on a white background. How do I do that in the GIMP or other program?

Is it just those two colors, with large uniform areas and simple boundaries? Just floodfill the white part to some other (temporary) color, then floodfill the original color to white, then floodfill the temporary color to the color you want. You can do that in Paint, or pretty much any other doodling program. If the boundaries are more complicated, or there are a lot of disconnected regions, many programs have a “magic tool” of some sort that replaces one color with another.

As an aside, JPG is about the worst image format to use for something like that, but I imagine that you’re not the one who made the original decision.

Ok, that worked well enough. I just figured there was an easy feature to do that I was missing.

In GIMP, click on the Colors menu and “invert” is about halfway down.

Actually, here is a screenshot, but I use Linux so it’s possible that the menus are different on other operating systems. If it’s not in the same location it’s gotta be around there somewhere.

http://img207.imageshack.us/img207/6357/snap1kv.jpg

If that works the same way Invert does in Photoshop, that won’t simply switch the two colors, it will change them to their photographic opposites; black will turn to white, red to green, etc.

Anyway, it sounds like he’s got the problem solved.

I’m really, really surprised this worked, especially with a JPEG, as they usually have fuzzy edges. I can think of three methods I might use for this sort of thing, and the easiest for a JPEG is as follows:

[ol]
[li]Enlarge the image to 400% using Image > Scale Image. Any interpolation method is fine except “None”.[/li]
[li]Convert the image to a 2-color image by using Image > Mode > Indexed, and setting the maximum number of colors to 2. [/li]
[li]Convert the image back to full-color by using Image > Mode > RGB.[/li]
[li]Now perform Chronos’s method* of swapping the colors. [/li]
[li]Then, to get the image back to the right size, reduce the image to 25% using Image > Resize image. The different color interpolation mods will have different effects: Sync will produce the sharpest edges, “Linear” the fuzziest, and “Cubic” in the middle. “None” will create an image effect known as “jaggies” that you probably don’t want.[/li]
[li]If even using “Linear” mode above produces edges that are too sharp, use one of the Filter > Blur commands to get the original blurriness back. Usually, though, this won’t be necessary.[/li][/ol]

Not only will this result in an “inverted” image, but it will also remove nearly all of those pesky JPEG artifacts. This is a good thing even if you plan on saving the result as a JPEG again, as repeatedly saving a JPEG leads to image degradation.

*Full version of Chronos’s method, for those who need it: [ol]
[li]Use the color picker to find the color of the colored portion of the image. [/li][li]Use the arrows beside the colors in the toolbar swap the foreground and background colors. [/li][li]Change the foreground color to a neutral color (I’ll use black). [/li][li]Fill the colored portion of the image with the black. Switch the foreground and background colors again, and fill the white portion of the image with the color from step 1. [/li][li]Change the foreground color to white and fill the black portion with white.[/li][/ol]

Almost—in the RGB colour space used by GIMP, the opposite of red isn’t green; it’s cyan. Magenta is the opposite of green.

Solutions mentioned (with the exception of “Invert colors” which isn’t quite what’s wanted) assume the image has only two colors – or is forced to two colors by changing its Mode. But what if, e.g. due to shadows, there are light grays within the white, and shades within the colored? You don’t want to destroy this shading information.

GIMP has some options to deal with this, but I’ve never figured them out, or got them to work. When I’m faced with such a problem, I convert the image to a very simple format like PBM, and (using a very simple program called a.out :cool: ) apply a trivial transform to each pixel.

Oops you’re right, I read it as white on black background.

I plead late night posting; this IS what Photoshop does.

Yeah, I recognized that as a possibility, but didn’t offer any suggestions for that because I didn’t have a clue how to do it (other than writing a custom program, as you allude to).

In that case, I would need to see the image and would probably wind up just kinda freeforming it. I might be able to use the color erase mode for the various tools in Gimp, or use Color > Color to Alpha to remove one color while leaving behind the shading. All of this would also involve using the color select tool to isolate portions, and using new layers to replace them.

I can’t be more specific than that without seeing an image. If you can do it programatically, then there’s probably a GIMP plugin out there that does this. I am unaware of any that come with the GIMP, but I am only self-taught, and have not encountered this problem outside this thread.

If there’s not a plugin, you might want to look into creating one. The plugin system can handle pixel by pixel transforms (though it groups them in 8 by 8 blocks).

I had a high quality JPEG and it is only two colors, so it worked well enough. I have the logo in .ai and .eps, but no programs to edit those files.

GIMP has some Color Transform tools (which I guess can be applied either to whole image or a selection) which may do the trick.

GIMP is complicated and I have great trouble figuring out how to do what I want … or even remembering a technique once I’ve worked it out. I can’t say this is GIMP’s fault; it’s more a matter of my aging brain and that I don’t use GIMP much.

Once upon a time I developed image-processing routines, though most of the algorithms were not my own. For example, I implemented Pfizer’s Adaptive Histogram Equalization, a nifty method essential for some problems but which I’ve not seen in Photoshop or GIMP. Is it available in add-on form?

Try Inkscape.