问题
I use Imagick to convert pdf to JPG. The problem is that pdf is in CMYK format and the colors from resulting jpg is slightly different from those from pdf. I use the following code to achieve the result:
$filelist = array("D3807797-8425-5-1_40.pdf[2]","D3807797-8425-5-1_40.pdf[3]");
$all = new Imagick();
foreach($filelist as $file){
$im = new Imagick($file);
$all->addImage($im);
}
$all->resetIterator();
$combined = $all->appendImages(true);
$combined->setImageFormat("jpg");
$combined->writeImage("test.jpg");
I also tried a linux command for this
$cmd = "gm convert -density 150x150 {$pdf}[2] {$pdf}[3] -append -quality 100 {$image}";
exec($cmd)
And i get the same result.
Could somebody help me with this problem? Thanks in advance.
回答1:
I cannot say definitive what is different (I for one do not see much difference between the image and pdf). But a good possibility is the conversion routine used to convert the CMYK channels to RGB. PDF uses the following formula:
- red = 1 - min( 1, cyan + black )
- green = 1 - min( 1, magenta + black )
- blue = 1 - min( 1, yellow + black )
And there are other formulas around yielding different results, perhaps the conversion used by your tooling isn't the prescribed one in the PDF standard.
Note that in the PDF file specified I do see that both DeviceRGB and DeviceCMYK are used; everything is vector based, no images are present.
来源:https://stackoverflow.com/questions/8801633/php-imagick-cmyk-pdf-convert-to-jpg