Page 1 of 1
converting a png with an ICC profile?
Posted: 2012-12-13T14:06:23-07:00
by jedierikb
I can convert a jpg from one ICC to another ICC.
[code]convert rgb_image.jpg -profile USCoat.icm cmyk_image.jpg[/code]
Or I can convert a jpg with no ICC to another ICC.
[code] convert rgb_image.jpg +profile icm \
-profile sRGB.icc -profile USCoat.icm cmyk_image.jpg[/code]
But how do I convert a png's pixels into the gamut described by an ICC profile? I understand I cannot embed the profile into the image file, but would at least like to convert the colors.
When I reuse the above commands, the colors come out wrong... (different from the same colors in the JPG when converted).
Any suggestions?
Re: converting a png with an ICC profile?
Posted: 2012-12-13T15:19:26-07:00
by snibgo
I'm not sure if I understand the question, but I'll have a go at answering it.
If an input file has no embedded profile, "-profile" will just add a new embedded profile. If it already has one, the pixel values will change to transform from the new to the old profile, and the new profile will be embedded, replacing the old one.
... creates a PNG with no profile.
Code: Select all
convert -verbose rose.png -profile sRGB.icc -profile snibgoGBR.icc +profile * roseGBR.png
... embeds the sRGB profile (which would have no effect as the image is already sRGB), then applies the snibgoGBR profile (which is designed to reverse the R and G channels). This second "-profile" will change pixel values. "+profile *" removes all embedded profiles.
Voila: a green rose.
Re: converting a png with an ICC profile?
Posted: 2012-12-13T15:25:18-07:00
by jedierikb
This is the source image:
http://alumni.media.mit.edu/~erikb/tmp/RED_JPG.jpg
And here is what I am trying:
Code: Select all
convert RED_JPG.jpg +profile icm -profile sRGB_v4_ICC_preference.icc -profile USWebUncoated.icc CMYK_PNG.png
and this is what I am getting:
http://alumni.media.mit.edu/~erikb/tmp/CMYK_PNG.png
I was hoping to get an image with the same colors as a JPEG run through the same command:
Code: Select all
convert RED_JPG.jpg +profile icm -profile sRGB_v4_ICC_preference.icc -profile USWebUncoated.icc CMYK_JPG.jpg
resulting in:
http://alumni.media.mit.edu/~erikb/tmp/CMYK_JPG.jpg
this image, CMYK_JPG.jpg, is what I am trying to reproduce pixel for pixel in a PNG file.
Re: converting a png with an ICC profile?
Posted: 2012-12-13T15:57:31-07:00
by snibgo
jedierikb wrote:this image, CMYK_JPG.jpg, is what I am trying to reproduce pixel by pixel in a PNG file.
Sorry, I don't understand. The pixel values will be different. The JPG file is CMYK. The PNG file is RGB. The pixel values will be different.
Re: converting a png with an ICC profile?
Posted: 2012-12-13T16:15:18-07:00
by jedierikb
I appreciate the confusion.
In photoshop I can open the rgb jpg and save it as a png, and then reopen that png and covert it to an icc cmyk profile. When I save that png, it's colors are what I am trying to match.
Re: converting a png with an ICC profile?
Posted: 2012-12-13T16:30:12-07:00
by snibgo
So, you have an RGB file and a CMYK file, and you are trying to match the colours on the screen. Is that correct? If so, why? CMYK is for printing; RGB is for screens. The gamuts overlap but each has colours that can't be reproduced in the other.
Your RED_JPG.jpg is very nearly pure red, and pure colours are where the gamuts don't overlap.
Re: converting a png with an ICC profile?
Posted: 2012-12-13T17:27:36-07:00
by glennrp
jedierikb wrote: I understand I cannot embed the profile into the image file, but...
"convert" does in fact embed the ICC profile into the PNG file, as the iCCP chunk. However, if
the profile is recognized to be sRGB then it only embeds an "sRGB" chunk. Any PNG
decoder finding the sRGB chunk is supposed to expand it back to the sRGB ICC profile.
Re: converting a png with an ICC profile?
Posted: 2012-12-13T17:51:17-07:00
by jedierikb
I am building an application, wherein different images, of different formats, can be composited on top of each other. This is so the user can get a preview of the composition.
The resultant composition, exported when the user is satisfied with their composition, will always be in a specific ICC profile for printing.
The way the composition system is architected, I need each layer to look like it is in the specific ICC profile so that the user can get a quick preview of what the final image will be (stacked in the right z-order). I am also planning to show the layers in a 3-d mode too (sort of like an old-type pop-up book).
If all of the layers were opaque, I could just stick with JPEGs and be done. But since I need to support alpha channels in the composition, I am looking for a way to convert PNGs with an alpha channel so they look like they are in the same gamut.
Re: converting a png with an ICC profile?
Posted: 2012-12-13T18:45:14-07:00
by snibgo
Okay. This general procedure, of displaying CMYK files on screen, is known as "softproofing". A couple of good introductions on how to do it in Photoshop:
http://www.cambridgeincolour.com/tutori ... oofing.htm
http://www.luminous-landscape.com/tutor ... fing.shtml
Those pages discuss how photographers do it. Requirements for other mediums differ; sometimes high saturation should be maintained at the expense of hue or tone.
Re: converting a png with an ICC profile?
Posted: 2012-12-13T19:16:51-07:00
by jedierikb
Thank you, I will look more into subproofing.
However, as I mentioned, I am alredy able to accomplish the specific task I am trying to accomplish already in Photoshop. The steps: I can open a PNG, Convert to Profile [ICC], and save as PNG. When I re-open the resultant png, its pixels look right.
Surely there is a way to replicate these steps in ImageMagick?
Re: converting a png with an ICC profile?
Posted: 2012-12-13T20:00:52-07:00
by fmw42
Open your file in PS, then go to the Color Settings in Photoshop and open that window. Note what profiles are set and also the Dot Gain. I suspect that the Dot Gain is changing things in PS and you would either need to turn off the Dot Gain and save. Then possibly IM will be able to match that with the very same profiles. Search Google for Dot Gain and Photoshop to see more details.
Re: converting a png with an ICC profile?
Posted: 2012-12-13T20:15:51-07:00
by jedierikb
I think I am able to accomplish what I set out to do, albeit without alpha channel support, with these steps:
Code: Select all
convert src_rgb.png src_rgb.jpg
convert src_rgb.jpg +profile icm -profile sRGB_v4_ICC_preference.icc -profile USWebUncoated.icc src_cmyk.jpg
convert -profile sRGB_v4_ICC_preference.icc src_cmyk.jpg dest_cmyk.png
dest_cmyk.png is a file whose pixels are in the USWebUncoated.icc gamut. It is, unfortunately, missing an alpha channel (if there was one in the original PNG).
Is there an easier way to bundle these three commands into one? And any ideas on the alpha channel?
Re: converting a png with an ICC profile?
Posted: 2012-12-13T21:09:35-07:00
by jedierikb
and, to add the opacity back to the converted image:
Code: Select all
convert dest_cmyk.png src_rgb.png -compose copy-opacity -composite dest_cmyk_alpha.png
Re: converting a png with an ICC profile?
Posted: 2012-12-13T21:12:07-07:00
by fmw42
You lose your transparency when converting from png to jpg in your first step, because jpg does not support transparency. You will need to copy the alpha channel from your original png and save it for later combining with your final png image.
Re: converting a png with an ICC profile?
Posted: 2012-12-14T03:03:26-07:00
by snibgo
You might also find that tiff is a useful format for your purpose. It can store CMYK and alpha channels.