Inefficient compression of CMYK images

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
elmimmo
Posts: 26
Joined: 2011-02-02T05:42:42-07:00
Authentication code: 8675308

Inefficient compression of CMYK images

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Inefficient compression of CMYK images

Post 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.
elmimmo
Posts: 26
Joined: 2011-02-02T05:42:42-07:00
Authentication code: 8675308

Re: Inefficient compression of CMYK images

Post 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.
elmimmo
Posts: 26
Joined: 2011-02-02T05:42:42-07:00
Authentication code: 8675308

Re: Inefficient compression of CMYK images

Post 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.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Inefficient compression of CMYK images

Post by dlemstra »

Feel free to open an issue on GitHub so we can keep track of it and maybe someone else will fix it.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Inefficient compression of CMYK images

Post by magick »

Add

Code: Select all

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