Which image compression is better, LZW or ZIP? I am using Lightroom to export images.
-
7\$\begingroup\$ Just in case there was any doubt: Both LZW and ZIP are lossless compression, so there's no degradation of image quality with either. The "best" algorithm will pretty much be whichever one produces smaller files, although there could also be compatibility issues with older software, as Joanne C mentioned in his response. \$\endgroup\$– coneslayerApr 14, 2011 at 1:44
-
1\$\begingroup\$ I'd suggest you test with a typical subset of your own images. LZW+Prediction gives smaller results with my typical 24bit-pictures and software ... but you use something different. \$\endgroup\$– LeonidasApr 14, 2011 at 14:04
-
\$\begingroup\$ You can also use ZIP after LZW compression. \$\endgroup\$– Count IblisJun 9, 2015 at 13:12
3 Answers
Better is a relative term and, to some degree, will vary in terms of amount between the two depending on a variety of factors including the bit-depth, frequency of discrete colours, etc. Some experimentation may be necessary on this front, though my reading indicates LZW is good for lower bit-depth images with lots of the same colours and tones in it and ZIP for when that is not the case. In other words, if the image is 8 bits go LZW and if it is 16 bits go with ZIP, as a rule of thumb, but with the caveat that it's not an absolute rule and there may be exceptions.
The only other thing I'd note is that LZW has been in the TIFF standard since 1992 and ZIP since 2002 (as part of a supplement when Adobe added it). While that's probably more than enough time for it to no longer be an issue, there may be the odd piece of software out there that handles LZW compression but not ZIP.
Compression is something you can see yourself, so I'll focus on interoperability and long-term preservation.
The EU's Succeed 2014 Recommendations for metadata and data formats for online availability and long-term preservation recommend "Uncompressed or LZW compression" for TIFF masters (p. 68) and note that «If files are actively managed in a digital repository, it is possible to consider using either LZW or ZIP lossless compression for the TIFF files. JPEG compression should not be used within the TIFF format. [...] Most of the respondents use uncompressed images (64%), if compression is used then LZW is mostly used».
In practice, I'm not sure there is a difference for single-page TIFF files. I did find problematic TIFF files whose compression upset my open-source program in the past, but I don't remember what was the exact culprit. LZW was patented until 2003. Based on the data above, however, it's possible that commercial support is more used to LZW and some software may still be poorly tested with ZIP/deflate TIFFs...
Make sure not to introduce some data loss yourself. It's easy to accidentally strip EXIF or IPTC/XMP metadata from your files while converting. Example commands with imagemagick and vips: mogrify -compress LZW -path /target/directory/ /input/path/*tif
(or -compress Zip
); vips tiffsave input.tif output.tif --compression deflate
.
-
1\$\begingroup\$ In my limited tests, Zip/Deflate often takes 3 times the time LZW does, for a 10 % or so gain in space. \$\endgroup\$– NemoOct 5, 2015 at 13:28
For the fastest save times you want to go with no compression. Adding compression can multiply the time required to save a TIFF by 5x on 16-bit TIFF files and by 10-15x on 8-bit TIFF files. Storage is so cheap these days that the time to save files can be more costly than the cost of adding additional storage, especially with 16-bit files where you're only trimming 15-20% off the total file size with compression.
If you want to use compression, because saving the storage space is important to you or you're turning out hundreds of TIFF files per day, when saving 8-bit TIFF files use LZW and when saving 16-bit TIFF files use ZIP. On 8-bit TIFF files the difference in file size between LZW and ZIP is negligible, but ZIP takes 2-3x as long to save. On 16-bit TIFF files LZW often makes files that are larger than both ZIP or uncompressed TIFF files, so if you're going to use compression on 16-bit TIFF files skip LZW and use ZIP instead.
IN SUMMARY
Fastest Save Times: No Compression
8-bit TIFF Files: LZW Compression
16-bit TIFF Files: ZIP Compression