CMYK to RGB

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
BeckhamStZ

CMYK to RGB

Post by BeckhamStZ »

Hello guys. I'm newbie with Imagemagick.
I want to convert CMYK color to RGB color, but many algorithms which I found doesnt work correctly.
( For example CMYK 0 100 100 0 convert to RGB 255 0 0 but in Adobe Photoshop the RGB Value is not this and also the G and B channels aren't zero )
Is there a way to use Imagemagick to get RGB value of Cmyk color?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: CMYK to RGB

Post by fmw42 »

in command line

convert -size 1x1 xc:"cmyk(100,50,25,10)" -colorspace RGB txt:

or

use the color converter at http://www.imagemagick.org/script/color.php

Note: for more exact conversion of a CMYK image to RGB you need to use profiles. see http://www.imagemagick.org/Usage/formats/#profiles
BeckhamStZ

Re: CMYK to RGB

Post by BeckhamStZ »

I want to use it in php to create text with rgb color from cmyk color. I try with profiles in command line and everything is ok but now in php is not.

Code: Select all

$im = new Imagick();

$im->newImage( 100, 100, new ImagickPixel('cmyk(0,100,100,0)'), 'jpeg');
$im->setImageColorSpace(Imagick::COLORSPACE_CMYK);

header('Content-Type: image/jpeg');
echo $im;
this code make a picture not in cmyk ( its in RGB ) and when I get ImagePixel from x=5 y=5 for example his value is rgb(0,100,100)
Where is the problem ?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: CMYK to RGB

Post by fmw42 »

Don't know much about Imagick, but try swapping the order of these two lines

Code: Select all

$im->newImage( 100, 100, new ImagickPixel('cmyk(0,100,100,0)'), 'jpeg');
$im->setImageColorSpace(Imagick::COLORSPACE_CMYK);
Do you know if IMagick allows colors to be specified in CMYK?
BeckhamStZ

Re: CMYK to RGB

Post by BeckhamStZ »

When swap two lines the result is this ->
Can not process empty Imagick object.

when I add a profiles and call getImageProfiles the returned array is empty.
cyklop
Posts: 7
Joined: 2010-06-10T22:20:58-07:00
Authentication code: 8675308

Re: CMYK to RGB

Post by cyklop »

Did you found a solution?
Post Reply