I don't have possibility to run convert
via cmdline and the only way to use Imagick is via the PHP5 wrapper. I would need to run following command:
convert in.jpg -channel RGB -auto-level +level-colors red,white out.jpg
Unfortunately I haven't found in documentation any method that would perform any of these options. Can somebody with better knowledge of the php wrapper help?
I found only Imagick::levelImage()
but couldn't simulate -auto-level
and level-colors
is nowhere to be found.
Thanks for help
In the end I got help on imagemagick forum, so for anybody with similar problem, here is what worked for me.
$img = new Imagick('in.jpg');
// grayscale image
$img->modulateImage(100, 0, 100);
// instead of auto-level option, where 65535 = Imagick::getQuantumRange()
$img->contrastStretchImage (0, 65535, Imagick::CHANNEL_ALL);
// instead of missing level-colors option, apply clut with the 2 desired colors
$clut = new Imagick();
$clut->newPseudoImage(1, 2, "gradient:red-white");
$img->clutImage($clut);
$img->writeImage('out.jpg');
For more info you can read the imagemagick thread