PHP Imagick Version
Now I have understood your needs, I have done an Imagick PHP version:
<?php
// Load input image
$image = new Imagick('landscape.jpg');
// Desaturate image
$image->modulateImage(100,0,100);
// Make duotone CLUT
$clut = new Imagick();
$clut->newPseudoImage(255,1,"gradient:darkblue-aqua");
// Apply duotone CLUT to image
$image->clutImage($clut);
// Output result
$image->writeImage('result.jpg');
?>
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:
convert -size 1x256! gradient:navy-orange duotone-clut.png
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:
convert -size 1x256! gradient:"rgb(255,255,0)-rgb(23,45,100)" ...
Here is how to desaturate your image to grey and then apply the CLUT:
convert landscape.jpg -modulate 100,0
-size 256x1! gradient:navy-orange -clut result.jpg
The -modulate
takes 3 parameters - Hue, Saturation and Lightness. By specifying 100,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:
convert -size 1x1! xc:yellow xc:magenta xc:cyan +append -resize 256x1! -scale x20 clut.png
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.
convert -size 1x1! xc:yellow xc:yellow xc:magenta xc:cyan +append -resize 256x1! clut.png
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 to tintImage()
in PHP, described here:
convert landscape.jpg -colorspace gray -fill "rgb(10,100,130)" -tint 100 result.png
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:
convert landscape.jpg -colorspace gray
( +clone -fill "rgb(10,100,130)" -colorize 100% )
-compose overlay -composite result.png