Page 1 of 1

Inefficient compression of CMYK images

Posted: 2018-04-25T01:17:49-07:00
by elmimmo
ImageMagick does not seem to efficiently compress TIFF CMYK images. Photoshop manages to Zip/LZW compress the same images to about 1/10 the size of what ImageMagick outputs.

If I create an LZW-compressed RGB TIFF with ImageMagick of a full rainbow gradient:

Code: Select all

convert -size 8500x5000 \
        -define gradient:angle=60 gradient:'#FFF-#0FF' \
        -set colorspace HSB -colorspace sRGB \
        -depth 8 \
        -compress LZW \
        ~/out-rgb.tif
The results are:
  • Output file size: 4.2MB
  • Photoshop re-save: 4.5MB
  • With `-compress none` or no `-compress` at all: 122MB
So about the same as Photoshop.

But if I create it as CMYK instead of RGB (or rather, convert it before output):

Code: Select all

convert -size 8500x5000 \
        -define gradient:angle=60 gradient:'#FFF-#0FF' \
        -set colorspace HSB -colorspace sRGB \
        -colorspace CMYK \
        -depth 8 \
        -compress LZW \
        ~/out-cmyk.tif
The results are:
  • Output file size: 77MB (already weird, for having just added one extra channel)
  • Photoshop re-save: 5.9MB
  • With `-compress none` or no `-compress` at all: 162MB
If I use Zip compression instead:
  • Output file size: 10MB (much better than LZW’s 77MB, but still humongous compared to the next bullet point)
  • Photoshop re-save: 0.83MB (!)
Version used:

Code: Select all

$ magick -version
Version: ImageMagick 7.0.7-28 Q16 x86_64 2018-04-17 http://www.imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
	Features: Cipher DPC HDRI Modules 
	Delegates (built-in): bzlib freetype jng jpeg lcms ltdl lzma png tiff xml zlib
and Adobe Photoshop CC 2015.5 17.0.0

Re: Inefficient compression of CMYK images

Posted: 2018-04-25T09:05:48-07:00
by fmw42
Imagemagick uses libtiff as a delegate to process tiff files. So you should inquire further on a TIFF forum or contact the libtiff developers.

Re: Inefficient compression of CMYK images

Posted: 2018-04-26T01:01:16-07:00
by elmimmo
fmw42 wrote: 2018-04-25T09:05:48-07:00 contact the libtiff developers.
Do you know how? The contact info for bug reports at libtiff.org refers to a mailing list whose interface returns 404 and a bugtracker whose domain does not even resolve.

UPDATE: Duh… Apparently libtiff.org is not the official site for libtiff anymore. Wikipedia states now it is http://simplesystems.org/libtiff/, whose links for the mailing list and bugtracker do work.

UPDATE2: Done. Here's the bug report.

Re: Inefficient compression of CMYK images

Posted: 2019-02-01T02:56:26-07:00
by elmimmo
The reason for the inefficient compression ratio of CMYK images has been found and explained in the comments of the bug report at tiffinfo, and it is indeed something that should be fixed in ImageMagik, not tiffinfo.

As a matter of fact, the issue, reason and potential solution was already hinted at back in 2010 but remained unaddressed.

Re: Inefficient compression of CMYK images

Posted: 2019-02-01T03:20:12-07:00
by dlemstra
Feel free to open an issue on GitHub so we can keep track of it and maybe someone else will fix it.

Re: Inefficient compression of CMYK images

Posted: 2019-02-02T05:31:02-07:00
by magick
Add

Code: Select all

-define tiff:predictor=2
to your command-line.