Page 1 of 1

i can not convert rgb picture to cmyk with php ?

Posted: 2013-11-22T16:47:09-07:00
by parisien
Hello.

I have a jpeg rgb file that i have to convert to cmyk.

The original file is here :
http://images.superspeed.fr/1.jpg

i use this code i found in a forum :

Code: Select all

                           <?php

$filePath = "1.jpg";
                        $i = new Imagick($filePath);
                         
                        $cs = $i->getImageColorspace();
                        
                        
                        if ($cs == Imagick::COLORSPACE_SRGB || 
                           $cs == Imagick::COLORSPACE_RGB){
                           print "Image is RGB<br/>\n";
                                                 

          

                         
                           $i->setImageColorspace(Imagick::COLORSPACE_CMYK);
                           $i->setImageFormat('jpeg');
                         
					$filePath = "1cmjn.jpg";
                           $i->writeImage($filePath);
                         
                        } else {
                           print "Image is not RGB<br/>\n";
                        }
                         
                        if ($cs == Imagick::COLORSPACE_CMYK) {
                         
                           print "Image is CMYK<br/>\n";
                        }
                         
 
                         
                        $i->clear();
                        $i->destroy();
                        $i = null;
and i get thar very ugly pic :
http://images.superspeed.fr

Do you know why ?

Re: i can not convert rgb picture to cmyk with php ?

Posted: 2013-11-22T18:18:20-07:00
by fmw42
Can you provide a link to the output? What you have provided does not seem to go to the same image?

In any case, presuming you have converted it successfully, many viewers/and browsers cannot view cmyk jpg images properly.

Re: i can not convert rgb picture to cmyk with php ?

Posted: 2013-11-22T18:23:57-07:00
by parisien
Sorry

here is the output file :
http://images.superspeed.fr/1cmjn.jpg

Thank you

Re: i can not convert rgb picture to cmyk with php ?

Posted: 2013-11-22T18:33:36-07:00
by fmw42
That is convert to cmyk jpg. IM will display it fine. If I drop it into my Safari browser, it does not look correct as I mentioned above. In Firefox and Opera and Chrome, it looks RGB, but too dark.

I get a good result as viewed in Firefox, Opera, and Chrome with Imagemagick 6.8.7.6 Q16, if I do

Code: Select all

<?php
exec("/usr/local/bin/convert 1.jpg -colorspace CMYK 1cmyk.jpg",$out,$returnval);
?>
but other viewers still cannot handle it properly.

You are using Imagick and I do not know that well. But know that it is not maintained well. Are you using a current version of IMagick and a current version of Imagemagick?


What version of Imagemagick is being used? The result may depend upon how old your Imagemagick version is?