Tool to apply gradient to texture

Related to this thread, but I assumed the problem was different enough to make a new thread. I also hope this is the most appropriate section.

Basically, I need a tool that would allow me to apply new colours to textures like this:

using a gradient like this one:

(Those two are compatible, if you want to try, you can)

You know, replacing a colour with another. I could do it manually, but it would take me ages for one texture, and there are over 50 more to do, with different gradients.

I’m no expert texturer, but I suppose it’s a bit like bump mapping, only reverse. I need to know what tool can do what I ask. Thanks in advance.