I create a cmyk image by php imagemagick, but cmyk color is different on photoshop?

£可爱£侵袭症+ 提交于 2019-12-01 12:32:39

问题


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?


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!