-
-
Notifications
You must be signed in to change notification settings - Fork 162
Description
So the scenario is a CMYK PDF which I'm trying to convert to an RGB image (jpg/png). For the longest time I've been using transformImageColorspace, as @Danack pointed out to me on StackOverflow.
However, a colleague recently had the same scenario and he used setColorspace. Both solutions apparently result in a CMYK ⇒ RGB conversion. However, there's a pretty significant difference between the results. Here's a result with a test PDF.
Now I wonder what is the reason for this difference, which conversion is more "thorough", if at all? Like for example, does either method respect any embedded color profiles in the PDF? Thanks.
For reference, here's a test snippet.
$i = new Imagick;
$i->setResolution(150, 150);
$i->setColorspace(Imagick::COLORSPACE_SRGB); // Method 1.
$i->readImage("$argv[1][0]");
// $i->transformImageColorspace(Imagick::COLORSPACE_SRGB); // Method 2.
$i->mergeImageLayers(Imagick::LAYERMETHOD_FLATTEN);
$i->writeImage("$argv[1]-converted-setColorspace.jpg");A third option would be commenting out the setColorspace line as well. That yields a CMYK jpg, which, if opened in my image viewer, looks the same as the image produced with transformImageColorspace.
