Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用Imagick::profileImage时,Imagick会产生负片图像_Php_Imagick - Fatal编程技术网

Php 使用Imagick::profileImage时,Imagick会产生负片图像

Php 使用Imagick::profileImage时,Imagick会产生负片图像,php,imagick,Php,Imagick,我使用PHP的Imagick扩展来处理图像。下面是我的代码 try{ $sourceimg=dirname(__FILE__)."\\source.jpg"; $destinationimg=dirname(__FILE__)."\\source_cmyk.tiff"; $im=new Imagick(); $im->setResolution(300,300); $im->readImage($sourceimg); $im->

我使用PHP的Imagick扩展来处理图像。下面是我的代码

try{
    $sourceimg=dirname(__FILE__)."\\source.jpg";
    $destinationimg=dirname(__FILE__)."\\source_cmyk.tiff";
    $im=new Imagick();
    $im->setResolution(300,300);
    $im->readImage($sourceimg);
    $im->setImageColorSpace(imagick::COLORSPACE_CMYK);
    $im->stripImage();
    $cmykprofile=@file_get_contents("C:\\USWebUncoated.icc");
    $im->profileImage("icm",$cmykprofile);
    $im->setImageDepth(8);
    $im->setImageUnits(1); //0=undefined, 1=pixelsperInch, 2=PixelsPerCentimeter
    $im->setResolution(300,300); //set output resolution to 300 dpi
    $im->setImageCompressionQuality(100);
    $im->writeImage($destinationimg);

}catch(ImagickException $e){
    echo $e->getMessage();
}
我遇到的问题是代码否定了原始图像。只有在使用
$im->profileImage
时,才会出现此问题。原因是什么?如何解决这个问题?我使用的配置文件是我从下载的cmyk颜色配置文件

我们将非常感谢您的帮助


谢谢

如果您使用的图像具有专门的颜色配置文件或非RGB图像(例如CMYK JPEG),则应首先将其转换为sRGB

使用条带配置文件,您还可以条带ICC颜色配置文件。大多数浏览器使用gamma 2.2(默认值)显示剥离图像,这与CMYK不同

您的问题的解决方案在用户提供的注释中: