NEED HELP! I create a cmyk image by php imagemagick, but cmyk color is different on photoshop! e.g.: set ImagickPixel color cmyk(0,0,0,100)(black), but found cmyk(61,61,61,0) on photoshop. why? and how to set the correct cmyk color?
You need to set the colorspace to CMYK, other wise your pixels will be converted to RGB.
$img->setImageColorspace(Imagick::COLORSPACE_CMYK);
http://php.net/manual/en/imagick.setimagecolorspace.php
Also all make sure that you are using file type that supports CMYK. ( eg. .jpg, .tif )
Edit
It seems Imagick has a bug.
Until it is fixed you can try and use this work around using transformImageColorspace
.
$draw = new \ImagickDraw();
$fillColor = new \ImagickPixel();
$fillColor->setColor('cmyk(0%,0%,0%,100%');
$draw->setFillColor($fillColor);
$draw->rectangle(100, 100, 400, 400);
$img = new \Imagick();
$img->newImage(500, 500, 'white');
$img->drawImage($draw);
$img->transformImageColorspace(Imagick::COLORSPACE_CMYK);
$img->setImageFormat("jpg");
header('Content-Type: image/'.$img->getImageFormat());
echo $img;
来源:https://stackoverflow.com/questions/37981616/i-create-a-cmyk-image-by-php-imagemagick-but-cmyk-color-is-different-on-photosh