使用imagick生成灰度差异图片
网络整理 - 08-16
imagemagick官方例子:convert cyclops.png -bordercolor white -border 1x1 -matte -fill none -fuzz 20% -draw 'matte 0,0 floodfill' -shave 1x1 cyclops_flood_3.png
imagick代码:
<?php
$image = new Imagick('cyclops.png');
$clone = $image->clone();
$clone = $image->fximage('p{0,0}');
$image->compositeImage($clone,imagick::COMPOSITE_DIFFERENCE,0,0);
$image->modulateImage(100, 0 , 0);
header( 'Content-Type: image/{$image->getImageFormat()}' );
echo $image->getImageBlob( );
//$image->writeImage('difference.png');
$image->clear();
$image->destroy();
?>
源图片: