Question

Using the Imagick php library, I wish to convert a CMYK pdf to a RGB jpg.

The following results in a jpg that does not represent the original colors even closely.

$thumb = new Imagick($file);
$thumb->setImageColorspace (imagick::COLORSPACE_RGB);
$thumb->setImageFormat('jpg');
$thumb->writeImage($target_file);

I have tried "profiles" but this results in the same issue as above and warnings. I also do not understand this approach.

    if ($thumb->getImageColorspace() == Imagick::COLORSPACE_CMYK) { 
       $profiles = $thumb->getImageProfiles('*', false); 
       $has_icc_profile = (array_search('icc', $profiles) !== false); 
       if ($has_icc_profile === false) { 
           $icc_cmyk = file_get_contents('/srv/www/htdocs/USWebUncoated.icc'); 
           $thumb->profileImage('icc', $icc_cmyk); 
           unset($icc_cmyk); 
       } 
       $icc_rgb = file_get_contents('/srv/www/htdocs/sRGB_v4_ICC_preference.icc'); 
       $thumb->profileImage('icc', $icc_rgb); 
       unset($icc_rgb); 
    } 

    $thumb->stripImage ();

Can anyone provide a solution that does not use exec() and uses the php library?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top