【问题标题】:PHP ImageMagick invert colorPHP ImageMagick 反转颜色
【发布时间】:2013-06-26 22:03:36
【问题描述】:

我正在开发一个 PHP 应用程序,该应用程序将自画像转换为铅笔画,并且该应用程序的一部分需要类似于以下示例的去饱和/反转图像:

反转前后:

创建去饱和图像很容易,但是如何使用 imagemagick 实现这种反转?我尝试使用negate,但失败得很惨。

这是我目前所拥有的:

 <?php
 $img = new Imagick();
 $img->readImage($image);
 $img->modulateImage(100, 0, 100); 
 $img->writeImage('image.png');
 ob_clean();                         
header('Content-Type: image/png'); 
echo $img;                          
$img->destroy();
 ?>

【问题讨论】:

标签: php image imagemagick


【解决方案1】:

根据this页面,可以通过PHP函数调用imagemagick过滤器:

function negateImage($imagePath, $grayOnly, $channel) {
$imagick = new Imagick(realpath($imagePath));
$imagick->negateImage($grayOnly, $channel);
header("Content-Type: image/jpg");
echo $imagick->getImageBlob();

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-03-05
    • 1970-01-01
    • 1970-01-01
    • 2011-06-08
    • 2021-09-23
    • 2013-07-24
    • 2011-06-05
    相关资源
    最近更新 更多