是否可以使用PHP5 imagick包装器



我不可能通过cmdline运行convert,使用Imagick的唯一方法是通过PHP5包装器。我需要运行以下命令:

convert in.jpg -channel RGB -auto-level +level-colors red,white out.jpg

不幸的是,我在文档中没有找到任何可以执行这些选项的方法。对php包装器有更好了解的人能提供帮助吗?

我只找到了Imagick::levelImage(),但无法模拟-auto-levellevel-colors

感谢的帮助

最后我在imagemagick论坛上得到了帮助,所以对于任何有类似问题的人来说,以下是对我有效的方法。

$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');

有关更多信息,您可以阅读imagemagik线程

最新更新