USAGE: cmyk2srgbjpeg input_image output_image_name_before_extention
First, cmyk2srgbjpeg checks whether input_image is CMYK. If not, it exits without further ado. Otherwise, cmyk2srgbjpeg imports the input image using the embedded ICC profile (with im_icc_import_embedded) and converts the result to sRGB (with im_icc_export). If there is no embedded ICC profile, or importing with the embedded profile fails (because the ICC is not compatible with CMYK, for example), cmyk2srgbjpeg substitutes a default and uses im_icc_transform, which combines the above two operations. The result is saved in output_image_name_before_extension.jpg.
You need to compile this program. See the source code for pointers.
Several options can be set through #defines:
- The path to the backstop ICC colour profile (current default: /usr/local/share/nip2/data/HP5000_UVDuraImageGlossMaxQ.icc);
- The path to an sRGB colour profile (current default: /usr/local/share/nip2/data/sRGB.icm);
- The return codes (current default: 0 if nothing was done (not CMYK), 1 if the program failed, 2 if conversion was performed with the backstop ICC because the embedded one "didn't work", 3 if this was done because there was no embedded ICC, and 4 if conversion was performed with the embedded ICC);
- The JPEG quality setting (current default: 99);
- The JPEG extension to be used for the output_image (current default: jpg); and
- The color conversion "intent" (current default: relative colorimetric).
I could have had these set with command line options instead, but the program was written for a high volume server environment for which speed of execution (and a small executable) matter more than on the fly configurability.
Code comments hopefully make everything clear.
Code comments hopefully make everything clear.
It should be easy to modify this driver to perform similar tasks.
The code can be downloaded from http://web.cs.laurentian.ca/nrobidoux/misc/cmyk2srgbjpeg.c. It is distributed under the Simplified BSD License. Improvements/bug reports/criticisms are welcome.
P.S.Crashes Now runs correctly on the apparently broken CMYK JPEG found at http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=19903&p=78647&hilit=cmyk#p78647. The ICC profile embedded in this image does not match its content: 3 band profile VS 4 band image. cmyk2srbgjpeg returns 2 and the result looks fine.
P.S. II You can poke around an image by loading it into nip2, left clicking on the bar on the left of its thumbnail, menuing Toolkits -> Colour -> ICC -> Import, and tinkering with the options after having double clicked on the thumbnail of the result to see it full size. Even if using Toolkits -> Colour -> ICC -> Export on the result with an sRGB profile (or going to Toolkits -> Colourspace -> sRGB), you generally will not get exactly the same results as cmyk2srgbjpeg, especially if the CMYK image has an embedded ICC profile which is understood by VIPS, because in this case the conversion is done in one step by cmyk2srgbjpeg instead of two separate steps that go through a linear float image format as it's done in nip2.
P.S. III Adobe source of ICC profiles: http://www.adobe.com/support/downloads/detail.jsp?ftpID=4075.
P.S. IV Best way to find CMYK images to test with AFAIK: google "cmyk.jpg" or "cmyk.jpeg" (taking the period out also works, as well as just googling "cmyk" or "cmyk images").
P.S. V Finally found a CMYK image (TIFF, not JPEG) that does not look good when passed through the program. It has no embedded ICC and appears to have been produced with a rather whacked one. It is discussed here: http://imagemagick.org/discourse-server/viewtopic.php?f=1&t=19717&p=79318#p79318.
P.S. VI It's likely a TIFF ("Thousands of Incompatible File Formats") issue. See http://imagemagick.org/discourse-server/viewtopic.php?f=1&t=19717&p=79318#p79332.
P.S.
P.S. II You can poke around an image by loading it into nip2, left clicking on the bar on the left of its thumbnail, menuing Toolkits -> Colour -> ICC -> Import, and tinkering with the options after having double clicked on the thumbnail of the result to see it full size. Even if using Toolkits -> Colour -> ICC -> Export on the result with an sRGB profile (or going to Toolkits -> Colourspace -> sRGB), you generally will not get exactly the same results as cmyk2srgbjpeg, especially if the CMYK image has an embedded ICC profile which is understood by VIPS, because in this case the conversion is done in one step by cmyk2srgbjpeg instead of two separate steps that go through a linear float image format as it's done in nip2.
P.S. III Adobe source of ICC profiles: http://www.adobe.com/support/downloads/detail.jsp?ftpID=4075.
P.S. IV Best way to find CMYK images to test with AFAIK: google "cmyk.jpg" or "cmyk.jpeg" (taking the period out also works, as well as just googling "cmyk" or "cmyk images").
P.S. V Finally found a CMYK image (TIFF, not JPEG) that does not look good when passed through the program. It has no embedded ICC and appears to have been produced with a rather whacked one. It is discussed here: http://imagemagick.org/discourse-server/viewtopic.php?f=1&t=19717&p=79318#p79318.
P.S. VI It's likely a TIFF ("Thousands of Incompatible File Formats") issue. See http://imagemagick.org/discourse-server/viewtopic.php?f=1&t=19717&p=79318#p79332.
No comments:
Post a Comment