Page 1 of 1

CMYK .tif to .jpg yields inaccurate color

Posted: 2015-11-06T18:12:32-07:00
by steve.trainor
New to IM and need your help. I'm converting CMYK .tif to .jpg with the code below. Although the profile is converted to RGB the color space is still CMYK when viewed in Photoshop. When viewed in web browser the image color is off, yellow tint. Any advise is appreciated. Also, being new, any suggestions on the code are welcome.

convert ‘*.tif'[0] -profile USWebCoatedSWOP.icc -profile sRGB.icc -strip -depth 8 -alpha set -layers flatten -resize 1200 -unsharp 0x0.2 -compress JPEG -quality 85% converted.jpg

Re: CMYK .tif to .jpg yields inaccurate color

Posted: 2015-11-06T19:20:12-07:00
by snibgo
Please post a sample input file. And tell us what version of IM you are using.

Re: CMYK .tif to .jpg yields inaccurate color

Posted: 2015-11-06T19:24:34-07:00
by fmw42
What version of IM and what platform? Please always provide that information.

Try putting -strip first after the input. Why the need for -alpha set before -layers flatten? If the tiff layer has transparency, then putting -alpha set is not needed. If if does not have transparency, then it also is not needed. If you are flattening with transparency, then you should specify the background color to flatten against. I think the default is white. I do not think you need -compress JPEG when converting to JPG. Also -quality does not need %.

Code: Select all

convert ‘*.tif'[0] -strip -profile USWebCoatedSWOP.icc -profile sRGB.icc -depth 8 -layers flatten -resize 1200 -unsharp 0x0.2 -quality 85 converted.jpg
If you still have trouble, then upload one image to some free hosting service such as dropbox.com and put the URL here, so others can check it out and test with it.

Edit: Sorry, snibgo, we were posting at the same time.

Re: CMYK .tif to .jpg yields inaccurate color

Posted: 2015-11-09T12:18:59-07:00
by steve.trainor
Thanks for the comments guys. I'm using IM on a Mac, version Version: ImageMagick 6.9.2-5 Q16 x86_64 2015-11-01

fmw42, I tried the edits you suggested, the file remains in CMYK color space and has the same color distortion when viewed in the browser.

Here is a link to the original image
http://we.tl/59e8ZC6njm

converted file is here
http://we.tl/KWCOMzS2Pm

Thanks again.

Re: CMYK .tif to .jpg yields inaccurate color

Posted: 2015-11-09T12:38:34-07:00
by fmw42
Since your image already has a USWebCoatedSwop profile, you do not need to specify it. I tried the following and it works fine for me on IM 6.9.2.5 Q16 Mac OSX. The resulting image is sRGB.

Code: Select all

convert newport123.tif[0] -profile /Users/fred/images/profiles/sRGB.icc \
-background white -flatten -resize 1200 -unsharp 0x0.2 \
-depth 8 -quality 85 tmp.jpg

Code: Select all

identify -verbose tmp.jpg

Code: Select all

Image: tmp.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 1200x900+0+0
  Resolution: 300x300
  Print size: 4x3
  Units: PixelsPerInch
  Type: TrueColor
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Pixels: 1080000
    Red:
      min: 46 (0.180392)
      max: 255 (1)
      mean: 250.331 (0.98169)
      standard deviation: 19.3294 (0.0758015)
      kurtosis: 30.6494
      skewness: -5.21035
      entropy: 0.12084
    Green:
      min: 35 (0.137255)
      max: 255 (1)
      mean: 249.904 (0.980014)
      standard deviation: 20.3139 (0.0796622)
      kurtosis: 26.0569
      skewness: -4.79276
      entropy: 0.121188
    Blue:
      min: 16 (0.0627451)
      max: 255 (1)
      mean: 248.18 (0.973253)
      standard deviation: 26.7205 (0.104786)
      kurtosis: 18.2485
      skewness: -4.26039
      entropy: 0.123364

This also works to remove the meta data. But removes the USWebCoatedSwop, so it must be added back

Code: Select all

convert newport123.tif[0] -strip \
-profile /Users/fred/images/profiles/USWebCoatedSwop.icc \
-profile /Users/fred/images/profiles/sRGB.icc \
-background white -flatten -resize 1200 -unsharp 0x0.2 \
-depth 8 -quality 85 tmp.jpg

Code: Select all

identify -verbose tmp.jpg

Code: Select all

Image: tmp.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 1200x900+0+0
  Resolution: 300x300
  Print size: 4x3
  Units: PixelsPerInch
  Type: TrueColor
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Pixels: 1080000
    Red:
      min: 46 (0.180392)
      max: 255 (1)
      mean: 250.331 (0.98169)
      standard deviation: 19.3294 (0.0758015)
      kurtosis: 30.6494
      skewness: -5.21035
      entropy: 0.12084
    Green:
      min: 35 (0.137255)
      max: 255 (1)
      mean: 249.904 (0.980014)
      standard deviation: 20.3139 (0.0796622)
      kurtosis: 26.0569
      skewness: -4.79276
      entropy: 0.121188
    Blue:
      min: 16 (0.0627451)
      max: 255 (1)
      mean: 248.18 (0.973253)
      standard deviation: 26.7205 (0.104786)
      kurtosis: 18.2485
      skewness: -4.26039
      entropy: 0.123364

Re: CMYK .tif to .jpg yields inaccurate color

Posted: 2015-11-09T15:37:24-07:00
by steve.trainor
The color is much better, THANK YOU! Next question :) I'm creating 7 derivatives from each .tif (1200w, 800w, 600w,400w, 300w, 200w, 100w) File size of the 1200 is 101kb, file size of the 100 w is 80kb – I expect the 100w to be <10kb. Any ideas? Files are here (don't mind the .pngs in the same folder) https://app.box.com/s/db2e2j4wmhfbjxdhp4o87hm0n6po8lhl

code from my developer
convert -profile /Users/Nirav/Work/newport551/hybris/bin/ext-platform-optional/mediaconversion/resources/mediaconversion/imagemagick/config/sRGB.icc -background white -flatten -resize 1200 -unsharp 0x0.2 -depth 8 -quality 85 -compress JPEG /Users/Nirav/Desktop/assets/TIF/newport123.tif /Users/Nirav/Desktop/assets/temp3/1200W.jpg


convert -profile /Users/Nirav/Work/newport551/hybris/bin/ext-platform-optional/mediaconversion/resources/mediaconversion/imagemagick/config/sRGB.icc -background white -flatten -resize 800 -unsharp 0x0.2 -depth 8 -quality 85 -compress JPEG /Users/Nirav/Desktop/assets/TIF/newport123.tif /Users/Nirav/Desktop/assets/temp3/800W.jpg


convert -profile /Users/Nirav/Work/newport551/hybris/bin/ext-platform-optional/mediaconversion/resources/mediaconversion/imagemagick/config/sRGB.icc -background white -flatten -resize 600 -unsharp 0x0.2 -depth 8 -quality 85 -compress JPEG /Users/Nirav/Desktop/assets/TIF/newport123.tif /Users/Nirav/Desktop/assets/temp3/600W.jpg


convert -profile /Users/Nirav/Work/newport551/hybris/bin/ext-platform-optional/mediaconversion/resources/mediaconversion/imagemagick/config/sRGB.icc -background white -flatten -resize 400 -unsharp 0x0.2 -depth 8 -quality 85 -compress JPEG /Users/Nirav/Desktop/assets/TIF/newport123.tif /Users/Nirav/Desktop/assets/temp3/400W.jpg


convert -profile /Users/Nirav/Work/newport551/hybris/bin/ext-platform-optional/mediaconversion/resources/mediaconversion/imagemagick/config/sRGB.icc -background white -flatten -resize 300 -unsharp 0x0.2 -depth 8 -quality 85 -compress JPEG /Users/Nirav/Desktop/assets/TIF/newport123.tif /Users/Nirav/Desktop/assets/temp3/300W.jpg


convert -profile /Users/Nirav/Work/newport551/hybris/bin/ext-platform-optional/mediaconversion/resources/mediaconversion/imagemagick/config/sRGB.icc -background white -flatten -resize 200 -unsharp 0x0.2 -depth 8 -quality 85 -compress JPEG /Users/Nirav/Desktop/assets/TIF/newport123.tif /Users/Nirav/Desktop/assets/temp3/200W.jpg


convert -profile /Users/Nirav/Work/newport551/hybris/bin/ext-platform-optional/mediaconversion/resources/mediaconversion/imagemagick/config/sRGB.icc -background white -flatten -resize 100 -unsharp 0x0.2 -depth 8 -quality 85 -compress JPEG /Users/Nirav/Desktop/assets/TIF/newport123.tif /Users/Nirav/Desktop/assets/temp3/100W.jpg

Re: CMYK .tif to .jpg yields inaccurate color

Posted: 2015-11-09T15:49:02-07:00
by fmw42
I do not know what -compress JPEG does when you are already specifying JPG for the output. Probably nothing. You may be reaching some limit on the compression for small images. It is probably not linear with the area as it would be for non-compressed images.

You should do all the processing in one command line. See http://www.imagemagick.org/Usage/files/#write

Do the profile change of colorspace and the flattening in the first command and then the resize and rest of the processing for each resize and sharpening, etc in each parentheses.

It would also run faster if you used +clone rather than -clone 0, so that you are resizing from the previous resize rather than the original. But if you want to resize from the original, then replace +clone with -clone 0 in the processing.