I’m trying to get this effect on images using imagick. In photoshop it’s called a gradient-map, but I can’t find anything similar to this in imagick.
I think I need to make it black-and-white first, but I don’t get how to add the colors after doing so.
Hope you can help! Thanks
— EDIT: —
- I’m using Imagick, not imagemagick.
- Notice there are two colors in the image, it’s not just colorized. Dark blue for the darker colors, and light green/aqua for the lighter ones.
2
Answers
PHP Imagick Version
Now I have understood your needs, I have done an Imagick PHP version:
Updated Answer
Oh, I think you want a “duotone” rather than a “tint”. Basically, you need to desaturate your image to mono, make a duotone CLUT (Colour Lookup Table) and apply that.
Here is how to make a CLUT:
This one will obviously make your dark tones navy and your highlights orange, but you can play around with the colours as you wish. You can also specify any shades of RGB (or HSL) as you wish with syntax like:
Here is how to desaturate your image to grey and then apply the CLUT:
The
-modulate
takes 3 parameters – Hue, Saturation and Lightness. By specifying100,0
I have left the Hue at 100% of whatever it was and reduced the Saturation to zero and left the Lightness unchanged.By the way, if you want a “tritone” with a 3 colours, one for shadow, one for midtones and one for highlights, you can make one like this:
Which gives this:
You can also move the crossover points around in the CLUT, either using a contrast-stretch or by having a bigger proportion of your CLUT populated by the same colours. Here I make the shadow colour “longer” by having 2 yellow blocks.
That gives “longer” shadows:
Obviously you can make a quadtone (quad-tone) too.
Original Answer
There are a number of ways of achieving the effect. So, starting with this image:
You could use
tint
like this, which corresponds totintImage()
in PHP, described here:Or you could clone your initial image and fill the clone with your tint colour and then composite that over the top of your image. You would use
colorizeImage()
in PHP, described here:There’s a library for PHP Imagick called pslayers and it allows you to do the exact kind of image layering and compositing that you are describing.
It even allows you to create interfaces to command line scrips for interacting with the command line version directly.