我试图将RGB图像转换为CMYK,因为它们需要打印。 我使用这个代码:使用Imagick将图像从RGB转换为CMYK
<?php
$filePath = 'rgb.jpg';
// First save image as png
$image = new Imagick($filePath);
$image->setImageCompression(Imagick::COMPRESSION_UNDEFINED);
$image->setImageCompressionQuality(0);
$image->setImageFormat("png");
$filePath = 'rgb.png';
$image->writeImage($filePath);
$image->clear();
$image->destroy();
$image = null;
// Convert colors
$image = new Imagick($filePath);
$image->stripImage();
$image->setImageColorspace(Imagick::COLORSPACE_CMYK);
$image->setImageCompression(Imagick::COMPRESSION_UNDEFINED);
$image->setImageCompressionQuality(0);
$image->setImageFormat("png");
$filePath = 'cmyk.png';
$image->writeImage($filePath);
$image->clear();
$image->destroy();
$image = null;
$fileUrl = 'http://www.product-designer.nl/rgb2cmyk/cmyk.png';
?>
CMYK Image:<br/>
<img src="<?php echo $fileUrl; ?>" width="400" /><br /><br />
<?php
$fileUrl = 'http://www.product-designer.nl/rgb2cmyk/rgb.png';
?>
RGB Image:<br/>
<img src="<?php echo $fileUrl ?>" width="400" />
你可以看到http://product-designer.nl/rgb2cmyk 的结果,我不知道怎么回事,但不知何故,图片上的颜色变成反转。 我需要转换图像,但颜色需要尽可能接近RGB颜色。
有谁知道如何做到这一点?
感谢
我有这个相同的问题..经过多次黑客攻击和研究,我解决了这个问题,请看我的答案。 – 2013-06-15 15:39:32