Page 1 of 1

CYMK Jpeg's to RGB Png.

Posted: 2006-12-19T09:29:24-07:00
by johnoyler
I'm having mixed success. Those Jpeg's that are already RGB resize fine, and I finally got the compositing done that I wanted. But every once in awhile, the final image looks like a polaroid left out in the sun for 5 weeks.

It occurred to me that some users might be uploading CYMK images from photoshop or something else. And, because I'm not doing any colorspace conversion (or even checking if it's needed), when I start all my compositing and resizing, and write it out to a PNG, it more or less dumps the K channel.

What do I need to do to account for this? Checking what colorspace an image is in seems easy enough, but it's less obvious what conversion I need to do after.

Posted: 2006-12-19T10:54:16-07:00
by magick
Check to see if the JPEG colorspace is CMYK. If it is use Profile() to add a SWOP profile (if it does not already have one) and call Profile() again with a sRGB profile. This forces a CMYK to RGB color conversion.

SWOP

Posted: 2006-12-19T11:13:52-07:00
by johnoyler
Assuming it doesn't have a SWOP profile, where can I find one? (I'm assuming it can be an external file?)

And would you be able to give some sort of pseudo-example?

Code: Select all

if ($image->Get('colorspace') eq "CMYK") {
 $image->Profile(name=>'newRGB', profile=>something);
 $image->Profile(something something?);
}
Is about the closest I can figure. Thank you for the help.

Ok...

Posted: 2006-12-19T16:15:04-07:00
by johnoyler
I've reinstalled IM with the lcms library, which wasn't there. I can confirm that it's built with that now.

I've googled around, and found swop and srgb files. http://color.org had the srgb.icc file, which is probably the correct one. Finding a proper swop file was more problematic, is one as good as another?

So far, I have this:

Code: Select all

 if ($image->Get('colorspace') eq "CMYK") {
  $image->Profile(profile=>'/data/art/composite/swop.icm');
  $image->Profile(profile=>'/data/art/composite/sRGB.icc');
 }
This seems to have no effect. No errors either, but I'm still getting the same washed-out look.

Strangely, if I simply resize $image, and write it out to a png file, it's pretty good (not perfect, some reds are too bright but still good enough). It's only that I do a resize, and then start compositing png's into it, before writing to a file, that causes this. It only happens with those jpegs that I can confirm are CMYK.

What am I doing wrong?

Posted: 2006-12-19T16:32:39-07:00
by magick
A standard CMYK profile is USWebCoatedSWOP.icc.

Type
  • identify -list configure
Be sure -llcms is associated with the LIBS name. If its not, ImageMagick cannot apply the color transform.

Confirmation.

Posted: 2006-12-20T08:31:11-07:00
by johnoyler
-llcms is associated with it. Double-checked. I've dug up a copy of the swop file you mentioned, I'm using it instead.

I'd hate to have to save the resize out to file, and re-open it before compositing just for this to work right.

For anyone that might have to do the same thing...

Posted: 2006-12-21T07:53:49-07:00
by johnoyler
The trick seems to be to do the (now) obvious

Code: Select all

$image->Set(colorspace=>'RGB');
After setting the profiles. Duh. And thanks magick, I do appreciate the help you gave.