使用Imagick将图像从RGB转换为CMYK [英] Convert image from RGB to CMYK with Imagick
本文介绍了使用Imagick将图像从RGB转换为CMYK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将RGB图像转换为CMYK,因为它们需要打印. 我正在使用此代码:
I'm trying to convert RGB images to CMYK, because they need to be printed. I'm using this code:
<?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颜色.
You can see the result on http://product-designer.nl/rgb2cmyk I don't know how, but somehow the colors on the image become inverted. I need to convert the image but the colors need to be as close to the RGB colors as possible.
有人知道怎么做吗?
谢谢
推荐答案
看看 查看全文