Page 1 of 1

JPEG compressed CMYK TIFF

Posted: 2011-05-03T05:29:24-07:00
by axelrose
Hello,

I'm sure this has been asked many times before but I cannot find a definite answer.

How do I need to configure libtiff (3.9.4) or libjpeg(8c) to allow for proper conversion
from CMYK to RGB?

I have a JPEG compressed TIFF file from Photoshop.
All currention IM version I compile will have inverted colors when doing

convert cmyk-jpeg.tif -colorspace rgb rgb.jpg

in "rgb.jpg".

I think this is because of my peculiar compilation of libtiff.

Thanks for any help,
Axel.

Re: JPEG compressed CMYK TIFF, libtiff question

Posted: 2011-05-03T10:00:42-07:00
by fmw42
Perhaps you should identify your version of IM and platform and also post a link to your file, so that others can test it.

Re: JPEG compressed CMYK TIFF, libtiff question

Posted: 2011-05-03T10:28:40-07:00
by axelrose

Code: Select all

> uname
Darwin

> convert -version
Version: ImageMagick 6.6.9-7 2011-05-03 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP OpenCL  

> otool -L convert
/tmp/im6697/ImageMagick-6.6.9-7/bin/convert:
	/tmp/im6697/ImageMagick-6.6.9-7/lib/libMagickCore.4.dylib (compatibility version 5.0.0, current version 5.1.0)
	/tmp/im6697/ImageMagick-6.6.9-7/lib/libMagickWand.4.dylib (compatibility version 5.0.0, current version 5.1.0)
	/tmp/im6697/ImageMagick-6.6.9-7/lib/liblcms2.2.dylib (compatibility version 3.0.0, current version 3.1.0)
	/tmp/im6697/ImageMagick-6.6.9-7/lib/libtiff.3.dylib (compatibility version 13.0.0, current version 13.4.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.10)
	/tmp/im6697/ImageMagick-6.6.9-7/lib/libfreetype.6.dylib (compatibility version 13.0.0, current version 13.2.0)
	/tmp/im6697/ImageMagick-6.6.9-7/lib/libjpeg.8.dylib (compatibility version 12.0.0, current version 12.0.0)
	/tmp/im6697/ImageMagick-6.6.9-7/lib/libpng15.15.dylib (compatibility version 18.0.0, current version 18.0.0)
	/tmp/im6697/ImageMagick-6.6.9-7/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.8.0)
	/tmp/im6697/ImageMagick-6.6.9-7/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.0.0)
	/tmp/im6697/ImageMagick-6.6.9-7/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
	/System/Library/Frameworks/OpenCL.framework/Versions/A/Libraries/libclparser.dylib (compatibility version 1.0.0, current version 1.0.0)
I'm executing this

Code: Select all

convert cmyk-jpeg.tif cmyk-jpeg.jpg
input file is http://dl.dropbox.com/u/84530/IM/cmyk-jpeg.tif

output file is Image

My suspect is the custom compilation of the "libtiff.3.dylib"
I configured libtiff this way:
---
Support for internal codecs:
CCITT Group 3 & 4 algorithms: yes
Macintosh PackBits algorithm: yes
LZW algorithm: yes
ThunderScan 4-bit RLE algorithm: yes
NeXT 2-bit RLE algorithm: yes
LogLuv high dynamic range encoding: yes

Support for external codecs:
ZLIB support: yes
Pixar log-format algorithm: yes
JPEG support: yes
Old JPEG support: yes
ISO JBIG support: no

C++ support: no

OpenGL support: no
---

Thanks for your help
Axel

Re: JPEG compressed CMYK TIFF, libtiff question

Posted: 2011-05-03T10:45:38-07:00
by fmw42
Your download link does not work for me.

Also I am not an expert on configuring delegates. All I can do is try to reproduce your problem or see if there is a work around.

But this is a common issue and many viewers do not show it properly without having some imbedded PS tags. This was reported not too long ago. I will see if I can find that topic.

see viewtopic.php?f=1&t=16512&hilit=cmyk+jpg+photoshop

I believe you were the one to find that issue/solution. So I am not sure where to go from here. But please fix your link and perhaps the IM developers or someone else more experienced can help.

Some browser don't handle cmyk jpgs correctly, also, as I understand it.

Re: JPEG compressed CMYK TIFF, libtiff question

Posted: 2011-05-03T11:49:11-07:00
by axelrose
The link for the input image is ok:

Code: Select all

curl http://dl.dropbox.com/u/84530/IM/cmyk-jpeg.tif -o /tmp/t.tif
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  152k  100  152k    0     0  98288      0  0:00:01  0:00:01 --:--:--  127k
~/work/censhare/censhare-3rdParty/build-669-7 > file /tmp/t.tif
/tmp/t.tif: TIFF image data, big-endian
Presumably your browser just doesn't like to display TIFF images.

In the other thread my proposal was to embed some extra PSD tags
to make peace with Apple preview.

In this case though I checked with Chrome and Firefox which don't have
those Apple Preview issues. They show inverted colors as well.

Still I believe it is some delegate library problem here.

Regards, Axel.

Re: JPEG compressed CMYK TIFF, libtiff question

Posted: 2011-05-03T23:30:40-07:00
by anthony
JPEG images with CMYK must contain a Color Profile so programs know what colors they should use when reading the JPEG.

That is the fact about JPEG file format. No color profile generally means the image is really sRGB.
We hope to have better sRGB handling in IM v7.

Re: JPEG compressed CMYK TIFF, libtiff question

Posted: 2011-05-03T23:54:35-07:00
by axelrose
JPEG images with CMYK must contain a Color Profile
My input file is TIFF (with JPEG compression).
So is your statement valid for CMYK TIFF as well?

Regards, Axel.

Re: JPEG compressed CMYK TIFF, libtiff question

Posted: 2011-05-04T00:38:06-07:00
by anthony
No but your output JPEG needs to have that profile added or any reader (like the web browser) will NOT work with that JPEG, as it will NOT think it is sRGB!

Either that our the color space changed to RGB or perhaps sRGB!

Re: JPEG compressed CMYK TIFF, libtiff question

Posted: 2011-05-04T01:40:48-07:00
by axelrose
That won't improve things.

using the provided TIFF input http://dl.dropbox.com/u/84530/IM/cmyk-jpeg.tif

Code: Select all

convert cmyk-jpeg.tif -profile SWOP.icc -profile sRGB.icm rgb.jpg
still shows false color, checked with various display programs.
Image

Is there anybody who can reproduce this?
If you have better colors -- which libtiff, libjpeg version, which IM version are you using?

Cheers, Axel

Re: JPEG compressed CMYK TIFF, libtiff question

Posted: 2011-05-04T02:11:00-07:00
by axelrose
I could well be that this is a libjpeg question. libjpeg documentation says:
CAUTION: it appears that Adobe Photoshop writes inverted data in CMYK JPEG files: 0 represents 100% ink coverage, rather than 0% ink as you'd expect. This is arguably a bug in Photoshop, but if you need to work with Photoshop CMYK files, you will have to deal with it in your application. We cannot "fix" this in the library by inverting the data during the CMYK<=>YCCK transform, because that would break other applications, notably Ghostscript. Photoshop versions prior to 3.0 write EPS files containing JPEG-encoded CMYK data in the same inverted-YCCK representation used in bare JPEG files, but the surrounding PostScript code performs an inversion using the PS image operator. I am told that Photoshop 3.0 will write uninverted YCCK in EPS/JPEG files, and will omit the PS-level inversion. (But the data polarity used in bare JPEG files will not change in 3.0.) In either case, the JPEG library must not invert the data itself, or else Ghostscript would read these EPS files incorrectly.
It doesn't look like there is some switch I can set for libjpeg.
Only IM itself could check and correct.

Regards, Axel

Re: JPEG compressed CMYK TIFF, libtiff question

Posted: 2011-05-04T06:16:04-07:00
by axelrose
I recompiled a rather old IM version 6.4.4-10 with otherwise the same configuration
parameters for IM and the libs (libtiff 3.9.4, libjpeg 8c)

The result is ok using a simple "convert cmyk-jpeg.tif -colorspace rgb rgb.jpg".

I assume that IM somehow lost the ability to work with the funny Photoshop
CMYK JPEG coding.

Axel