I would like to transform colors in the attached image (and other hundreds) defined by the following rule:

  • 1) the lightest blue became the light green (exactly like as in the upper right color sample rectangle),
  • 2) and the darkest blue became the dark green (exactly like as in the bottom right color sample)

I've tried to mod hue and lightness and can transform what satisfies 1) or 2) but not both at the same time.

Please note recreating the image with the 2 greens with gradient is not and option because I have many images with many details.

enter image description here

Thanks in advance

  • What format do you have these images in?
    – Yisela
    Commented Apr 24, 2014 at 10:05
  • RGB if you mean the color space. The format is PNG. Commented Apr 24, 2014 at 10:51
  • @g.pickardou welcome to the site. You mention hundreds of these - are they all the same colors that need to be switched?
    – Ryan
    Commented Apr 24, 2014 at 11:05
  • Hopefully. These are a website button, background etc .PNGs. However the designer was not too consistent using colors...I suppose you are asking this because of some batch automation solution using the very same color transformation. This is not an issue for me. I am glad to transform the images piece by piece if one can explain me how to solve this with one picture interactively, but not redoing the gradient, instead transforming colors. Commented Apr 24, 2014 at 11:46

2 Answers 2


Not quite sure what the big problem is other than tediousness, which is annoying. But hey bill hourly right :)

Image -> Adjustment -> Replace Color. (I started with the bottom one)

enter image description here

Image -> Adjustment -> Replace Color on the top, but here you have to watch the setting. Once you see the black turn grey you went too far. I marked this with the red pencil.:

enter image description here

Back up so the rest stays black:

enter image description here

And we're done

enter image description here

  • If turning gradients into solid colors is okay then yup, Replace Color can be used...although since colors are being "swapped" you'll need to mask it and do it in phases. Commented Apr 24, 2014 at 16:48
  • 1
    @ryan: Thx. Btw I can assure you it was not tediousness. I've spent hours with this, trying to use my old Paint Shop Pro, and latest PhotoShop trial. I did not mention, I am not a designer and I have no design skills at all, including terminology (like dithering, mentioned in an other answer) and using software. Anyway your answer is clear and helps. Commented Apr 25, 2014 at 9:20

As the images are apparently not dithered to create the gradient, you have more than four colors (two greens and two blues) here. Note the histogram for your sample:

enter image description here

So as you are perhaps aware, you are looking at a potentially subtle recoloring process. There's blue in you "greens", green in your "blues", and red in there too somewhere. Results will be subjective and up to you to decide if they are good enough.

(Note: As @Ryan's answer points out...if you don't mind losing all the gradients, you can achieve flat replacement of a color range with a single color using Image -> Adjustments -> Replace Color. You'll have to do some masking if you are doing multiple color range replacements that overlap each other, though.)

Were it me, I would ask the designer to provide assets of this type in source form...as opposed to needing to run this kind of filtering on the flattened and compressed output. It's hard to tell on such a small sample image, but I'd guess the colors have been web optimized because of the discrete gaps in the histogram; a continuous gradient would yield smoother distributions.

But if bugging the designer for source files isn't an option, you're up a bit of a creek as far as automated solutions go. Here's the pessimistic answer of "you can't":

How can I edit the colors in an already-placed, custom gradient in Photoshop?

Then again, you can bound regions, create masks from the gradient, use gradient maps to apply new gradients. Sky's the limit and anything is possible with a bit of cleverness (and the ability to place every pixel by hand if need be.)

You might get some ideas from this video as well: https://www.youtube.com/watch?v=pJedscmjaFQ

But I'd find out if the designer actually has non-flattened forms of these dozens/hundreds of buttons/etc. and can give you files with more structure. If so, get those originals. If not, get them to change their practices and/or don't hire them again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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