Page 1 of 1

IM produces CMYK JPG that Finder/preview opens incorrectly

Posted: 2010-06-25T07:37:36-07:00
by Monarobase
Hello,

I'm in the process of developing a PHP script to create CMYK PDF'S and I need to convert JPEG files to CMYK but have come across something strange and was wandering if you could give me some information about why this happens.

Here is my convert command :

Code: Select all

convert input.jpg  -profile cmyk.icc -colorspace CMYK output.jpg
When I convert a RVB JPEG file to CMYK with photoshop, with or without including a color profile I can see the correct colors in MacOSX Finder and Preview however when I do the same with ImageMagick with or without using '-strip' in the command the resulting image is mostly black in the finder, it opens fine in all adobe programs but not in the finder or preview.

I do not actually need the image to open correctly in the finder but am trying to work out why illustrator doesn't open PDF files that include CMYK images inserted by TCPDF correctly and for the first step I would like to understand what is so different between a CMYK JPEG file produced with ImageMagick and a CMYK JPEG file produced with Photoshop.

Thanks in advance.

Re: IM produces CMYK JPG that Finder/preview opens incorrect

Posted: 2010-06-25T08:24:00-07:00
by snibgo
I would like to understand what is so different between a CMYK JPEG file produced with ImageMagick and a CMYK JPEG file produced with Photoshop.
This forum may not have many folk who can directly answer the question. But if you post URLs to a sample of each, someone might take a look at them.

Re: IM produces CMYK JPG that Finder/preview opens incorrect

Posted: 2010-06-25T12:42:45-07:00
by Drarakel
A note regarding your command:
Monarobase wrote:

Code: Select all

convert input.jpg  -profile cmyk.icc -colorspace CMYK output.jpg
It seems that you are trying to do a conversion similar to Photoshop - i.e. a conversion with profiles - is that correct? Then this command won't always do that. If your input.jpg doesn't have an embedded color profile, then the conversion is done only with '-colorspace CMYK' (not as good as with profiles), and after that cmyk.icc gets embedded. You rather should use two profile parameters - one for the source profile (e.g. sRGB), the second for the destination profile. (If input.jpg has an embedded profile, then your former command is alright. You don't need the '-colorspace CMYK' though.)
See also here.

Regarding the different display of your images - I would also want to wait for sample files before I'm trying to answer...
When the display is not right - do the images look like inverted then?

Re: IM produces CMYK JPG that Finder/preview opens incorrect

Posted: 2010-07-12T09:16:43-07:00
by Monarobase
Hello again, sorry about the delay !

Yes the image looks inverted. I will try to post some screen shots asap.

As for the profiles, I will be try to remove the -colorspace CMYK and let you know about the result but I have already tried the opposite and got an inverted image :

I took a CMYK image converted with the previous command so it contains a CMYK profile a did this :

Code: Select all

convert inputcmyk.jpg  -profile srvb.icc outputrvb.jpg
I've got to do a series of tests though before asking you to help me out on this one to see if I cannot find the answer myself !

Re: IM produces CMYK JPG that Finder/preview opens incorrect

Posted: 2011-04-11T07:48:41-07:00
by axelrose
I can confirm this. Neither Apple's QuickView or Preview.app properly displays any CMYK JPEGs
created with current ImageMagick versions.

I just do

Code: Select all

convert logo: -profile rgb.icc -profile cmyk.icc -colorspace cmyk -strip logo.jpg
The output "logo.jpg" is ok. when checked in Photoshop but not in Finder or Preview.

exiftools shows those color specific entries in meta data:

Code: Select all

 <Adobe:DCTEncodeVersion>100</Adobe:DCTEncodeVersion>
 <Adobe:APP14Flags0>(none)</Adobe:APP14Flags0>
 <Adobe:APP14Flags1>(none)</Adobe:APP14Flags1>
 <Adobe:ColorTransform>Unknown (RGB or CMYK)</Adobe:ColorTransform>
Don't know, whether this is correct.

Cheers, Axel.

Re: IM produces CMYK JPG that Finder/preview opens incorrect

Posted: 2011-04-11T09:21:23-07:00
by axelrose
Out of curiosity I tried with an older IM 6.5.9-10.
The output there looks fine when viewed with Preview.app.

I contiue checking this later.

Re: IM produces CMYK JPG that Finder/preview opens incorrect

Posted: 2011-04-11T17:38:20-07:00
by anthony
I would be careful about reading and writing JPEG images just to set profiles. JPEG is lossy, when ever you write it you loose some information. To just add a color profile I would look at a loss-less method such as programs like jhead.

If the profiles actually MODIFY the actual data (changing color profiles) than that is fine, Imagemagick can do this, but you need at least two color profiles to do the conversion, the first either supplied with the image, or provided using the first -profile option. You can also simply remove the color profile and then provide it directly too.

Once the image has a profile (part of image or set), then the next color -profile option will re-map the pixel values, to match.

You must remember that ImagMagick is a Image processor, which will almost always read in and write out the image data, for processing purposes.


Note also that -colorspace is just a way of specifying the gross storage of color values, and simple color conversions. It is not nearly as exact as using -profiles.

Re: IM produces CMYK JPG that Finder/preview opens incorrect

Posted: 2011-04-11T20:03:35-07:00
by fmw42
convert logo: -profile Profiles/sRGB.icc -profile Profiles/cmyk.icc -colorspace cmyk -strip logo1.jpg
This is not really good at best it is overkill. The first profile converts to RGB, the second converts it to CMYK, the -colorspace tries to convert to CMYK again, the -strip removes the two first profiles.

This is adequate
convert logo: -colorspace cmyk logo2.jpg

or this

convert logo: -profile Profiles/sRGB.icc -profile Profiles/CMYK.icc logo3.jpg


However, for images with a cmyk profile, you need do nothing or add -strip at the beginning and then just do -colorspace

convert logo: -strip -colorspace CMYK logo4.jpg

or do -strip and add your own profile

convert logo: -strip -profile Profiles/sRGB.icc -profile Profiles/CMYK.icc logo5.jpg

HOWEVER, this is all a problem with Mac PREVIEW. If you display in Firefox, it looks just fine. Mac Preview and Safari (at least on my Tiger system) have had this problem with cmyk jpgs for as long as I know.

Re: IM produces CMYK JPG that Finder/preview opens incorrect

Posted: 2011-04-12T01:56:57-07:00
by axelrose
Thanks for keeping the topic alive.

Apple Preview seems to have a problem with CMYK JPEG. I tried again using different approaches like this:

Code: Select all

cd /tmp
rm -f logo-rgb.jpg logo-sips-cmyk.jpg logo-im-cmyk.jpg logo-psd-cmyk.jpg

convert logo: -profile rgb.icm logo-rgb.jpg

sips -m cmyk.icc logo-rgb.jpg --out logo-sips-cmyk.jpg
exiftool -ColorTransform logo-cmyk.jpg

convert logo-rgb.jpg -profile rgb.icm -profile cmyk.icc logo-im-cmyk.jpg
exiftool -ColorTransform logo-im-cmyk.jpg

# open "logo-rgb.jpg" in Photoshop and convert into profile "cmyk.icc", save as "logo-psd-cmyk.jpg"
exiftool -ColorTransform logo-psd-cmyk.jpg
The results Image
show that even CMYK JPEG produced with Apple's own "sips" isn't displayed properly
(though I'm not sure whether my usage of "sips" is correct)

But why is the result saved by Photoshop ok? I will try to investigate this further by
copying attribute by attribute from "logo-psd-cmyk.jpg" into "logo-im-cmyk.jpg" and
watching when Preview shows the desired result.

Regards, Axel.

Re: IM produces CMYK JPG that Finder/preview opens incorrect

Posted: 2011-04-12T05:13:32-07:00
by axelrose
It seems that Preview works fine if it finds Photoshop tags.
If I patch the IM produced CMYK JPEG with exiftool:

Code: Select all

cp logo-im-cmyk.jpg logo-im-patched.jpg
exiftool -tagsfromfile logo-psd-cmyk.jpg -photoshop:all logo-im-patched.jpg
Preview is displaying the result as expected.

Could I add the Photoshop profile during a "convert" command sequence?

Re: IM produces CMYK JPG that Finder/preview opens incorrect

Posted: 2011-04-12T09:44:46-07:00
by fmw42
That is an interesting result and workaround. However, as I said above this is really a Preview issue as Firefox display's the image properly.

Nevertheless, IM can read, but I don't know if it can write EXIF tags. See http://www.imagemagick.org/script/escape.php

This page seems to imply that you can write some profile information. See http://www.imagemagick.org/Usage/formats/#profiles

Exiftool is the general tool of choice for doing that if IM currently cannot.

Perhaps you should bring this up on the Developers forum. Some one there may have more information.

Keep us posted if you find a good method to correct cmyk jpgs for display in PREVIEW/Safari etc.

P.S. Others have told me that they don't see this problem on Mac Snow Leopard/INTEL hardware. My old Mac is Tiger/PowerPC

Re: IM produces CMYK JPG that Finder/preview opens incorrect

Posted: 2011-04-12T10:12:31-07:00
by axelrose
same problem with Snow Leopard and Intel CPU