Wednesday, May 11, 2011

GIMP Color Range Mapping

[note: This first section was typed in early February]

I've been a fan of the GIMP (GNU Image Manipulation Program) for a looong time. It's helped me create and modify and fake many, many pictures over the years.

A while ago, one of its features vanished. The code behind it was a mess, and the developers didn't see its value. It would have been a pain to go through and make it work the way a modern GIMP plug-in should, so it (along with other stuff which richly deserved to get culled) was lost. Overall, GIMP got better, but a handful of people including myself really wanted our color range mapping back.

We had some tricks. An old binary of the plug-in would still load and run happily on newer versions of GIMP until pretty recently. But GIMP has moved on, and at this point, that crufty old plug-in just won't cut it.

Well, long story short:
https://bugzilla.gnome.org/show_bug.cgi?id=641893

I fixed up the code, and submitted a patch. With any luck, future versions of GIMP will include my refactor of that good ol' plug-in.

Here's what it does, if you're curious:


You define a pair of source colors (usually colors from your current image) and another pair of colors as a destination. All areas of the image that match your source colors get changed to your destination colors, and, most importantly, all colors that are in between your source color pair get translated as colors between your destination pair. It's very useful for altering images that have anti-aliasing baked in, or large patches of color with subtle-but-important variation.

...As you might see from the discussion on gnome.org, even the developers don't really understand why this is so great, so don't feel bad if you didn't follow all that. :^)

[note: the following section is from today]

I've given up trying to convince the developers to take my patch. Or even look at it, it sounds like. It's too bad, but anyone else like me who wants the feature back can apply my code and have it. I'm tempted to babble about some of the common things that open/free software gets wrong when dealing with its community, but they're largely known.

Probably, I should have brought it to them as "here's a new feature" instead of "this went away and I've revived it". Then I'd only have had to climb the shallower "not-invented-here" incline instead of the steeper "we already decided no" one. Either way I'd have still faced "why would you want to do that", which is particularly obnoxious and spans all of software (and many other areas, I'm sure).

Ahh well, live and learn. Or, just live. :^)

[update: 2011-08-19]
to patch against stable release code (as opposed to the latest from the git repository) give this a try:
http://penduin.net/projects/color-range-mapping-2.6.x.patch

[update: 2018-01-10]
If building from source is not your cup of tea, others have figured out another clever way of resurrecting this feature:
http://billauer.co.il/blog/2010/06/gimp-map-color-range-mapping-64-bit/
https://wtanaka.com/node/7904

11 comments:

Anonymous said...

what I was looking for, thanks

Penduin said...

Great! Good to know my efforts at least helped out somebody.

Thomas Abernathy said...

I have been searching for this. Glad to see someone has done something about it. My problem is I've never had any luck compiling. Anyone have a file that may work for me? I have Gimp 2.6.8 on Ubuntu 10.04 32 bit. That would be greatly appreciated :)

Penduin said...

tjustleft: I'd be glad to either help you with the build (it's not hard to set up on Ubuntu) or try and get you a binary. I'm on 64-bit which makes it trickier for me to build a 32-bit version, but I'm sure we can figure something out.

Thomas Abernathy said...

Thank you, that would be great. I should have went with 64 bit but at the time I wanted to ensure all my previous programs would run.

I read that Bugzilla conversation and was a little surprised. "There was a good reason why this plug-in was removed." Period. I'm more used to that attitude from the windows community.

Penduin said...

tjustleft: can you either list your email address on your blogger profile or send me an email directly?
owenswerk@gmail.com

Thomas Abernathy said...

I just listed my address on my profile.

Anonymous said...

Does this work with GIMP-2.8 Windows 64-bit? Tx.

Doctoru said...

This is an extremely important feature, I don't understand why they removed it. Do you know if your patch also works with GIMP 2.8? I have never built GIMP from source but I will give it a try if this is the only way to get the "Map Color Range" plug-in working again. Thanks.

Penduin said...

I think I did get it working on 2.8, I don't remember if the patch needed changes or not. Should work on Windows too, but I'm the wrong person to ask about building there. Email me if you need help (from my profile page)

rtdrury said...

Let's say you have some red text on a black background. Zoom in and see that the transition pixels smoothly fade from red to black. Your client requests a change of text color from red to green. Color range mapping allowed you to easily change the range of red->black to a new range of green->black. Piece of cake. Now I will guess that the developers have other ideas on how to do this, like cut the black out using their feather edge selection tool, yada yada. Then six more highly non-intuitive steps to complete.

The color range mapping is the most direct, intuitive approach. Direct good. Intuitive good. Other way bad. Real bad.