i can not convert rgb picture to cmyk with php ?

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
parisien
Posts: 2
Joined: 2013-11-22T16:37:08-07:00
Authentication code: 6789

i can not convert rgb picture to cmyk with php ?

Post 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 ?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
parisien
Posts: 2
Joined: 2013-11-22T16:37:08-07:00
Authentication code: 6789

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

Post by parisien »

Sorry

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

Thank you
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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?
Post Reply