簡單範例
<?php
$image = new Imagick('test.jpg');
$CMYK_color_model = array(0,100,0,0);
$image->recolorImage($CMYK_color_model) ;
header('Content-type: image/jpg');
echo $image
?>
(PECL imagick 2 >= 2.3.0, PECL imagick 3)
Imagick::recolorImage — 重新著色影像
此函式自 Imagick 3.4.4 起已被 _棄用_。強烈建議不要依賴此函式。
平移、縮放、剪切或旋轉影像色彩。此方法支援可變大小的矩陣,但通常 RGBA 使用 5x5 矩陣,CMYK 使用 6x6 矩陣。最後一列應包含正規化值。如果 Imagick 是針對 ImageMagick 6.3.6 或更新版本編譯的,則可以使用此方法。
matrix (矩陣)
包含顏色值的矩陣
成功時返回 true
。
範例 #1 Imagick::recolorImage()
<?php
function recolorImage($imagePath) {
$imagick = new \Imagick(realpath($imagePath));
$remapColor = [ 1, 0, 0,
0, 0, 1,
0, 1, 0,];
//$remapColor = [
// 1.438, -0.122, -0.016, 0, 0, -0.03,
// -0.062, 1.378, -0.016, 0, 0, 0.05,
// -0.062, -0.122, 1.483, 0, 0, -0.02,
//];
@$imagick->recolorImage($remapColor);
header("Content-Type: image/jpg");
echo $imagick->getImageBlob();
}
?>
簡單範例
<?php
$image = new Imagick('test.jpg');
$CMYK_color_model = array(0,100,0,0);
$image->recolorImage($CMYK_color_model) ;
header('Content-type: image/jpg');
echo $image
?>