16

I several TIFF images in a folder. How can I determine which image compression algorithm they use?

When I do file I get

100 (2).tif:                 TIFF image data, little-endian
100.tif:                     TIFF image data, little-endian

These results don't say which algorithm is used, or even whether it's lossy or lossless. How can I figure this out? Solutions can be Windows- or Linux-based.

4
  • 1
    Looking at the image's extension should be enough.
    – Icarus
    Commented Mar 20, 2012 at 13:52
  • isn't the extension a sufficient information? else, file gives you the basic infos on a file (linux/macosx)
    – njzk2
    Commented Mar 20, 2012 at 13:52
  • 1
    Most compression algorithms include a header with a fixed tag of some form. It wouldn't be too much of a challenge to roll your own identifier.
    – adelphus
    Commented Mar 20, 2012 at 13:53
  • 1
    Icarus, you are supposing that tiff-files only use one compression algorithm. That is wrong. You have options like uncompressed, pack bits, lzw, zip and others.
    – r2d3
    Commented Feb 6 at 10:00

5 Answers 5

17

Use W_Whalley's identify -verbose suggestion instead. If you're in a linux/cygwin environment, pipe it to grep -i compression and you'll have your one-line answer. I.e.

identify -verbose /path/to/your/file.tiff | grep -i compression
1
  • That gives me “Zip” even though I've told GIMP to use Deflate. GIMP doesn't list "Zip" as an option. Any ideas of why it returns that? Commented Feb 1 at 14:53
4

If you have ImageMagick installed, use the display tool to show the image.

Right-click on the image and choose Image Info, then look for the Compression: setting (it's near the bottom of the list).

Or if you want the minimum information use the identify tool with the -verbose switch, then filter the result to look for the “Compression” line.

1
  • 2
    Your answer is correct, but the question was probably about finding out in an automated way (e.g. by using a command-line tool).
    – Floris
    Commented Jan 26, 2017 at 9:12
2

What about the file command? Example:

$ file /usr/share/apache2/icons/a.png
/usr/share/apache2/icons/a.png: PNG image, 20 x 22, 4-bit colormap, non-interlaced
8
  • 1
    But where is the name of the algorithm used ?
    – klijo
    Commented Mar 20, 2012 at 14:49
  • PNG is a compression algorithm (a lossless one). Image file formats are typically named after thier compression algorithm. The term "JPEG" for example, doesn't technically refer to a file type; it refers to a compression scheme. Colloquially the two are pretty universally conflated, but the type of image (TIFF, PNG, etc.) usually (but not always) refers to the compression algorithm used.
    – Zac B
    Commented Mar 20, 2012 at 15:04
  • 3
    TIFF can be made to work with both lossless and lossy compression. This is my real problem. I need to determine which of them uses lossy and which uses lossless and the name of the algorithm
    – klijo
    Commented Mar 20, 2012 at 15:14
  • Sorry, TIFF was a bad example. The TIFF format usually uses LZW, but there are (rare, but present) implementations of it that use other algorithms as well.
    – Zac B
    Commented Mar 20, 2012 at 15:16
  • 3
    Use W_Whalley's identify -verbose suggestion instead. If you're in a linux/cygwin environment, pipe it to grep compression and you'll have your one-line answer.
    – Zac B
    Commented Mar 20, 2012 at 17:21
1

identify works, but it's slow for big files.

identify -verbose

One may use tiffinfo instead.

tiffinfo test.tif | grep Compression

Use this command for installation (on Ubuntu):

apt-get install libtiff-tools
1
  • identify outputs merely TIFF64 1065x532 1065x532+0+0 8-bit sRGB 102592B 0.000u 0:00.000 on a Deflate-compressed TIFF, and tiffinfo isn't available for cpe:/o:opensuse:tumbleweed:20240216... :< Commented Feb 20 at 18:29
1

Another option would be exiftool. For example:

exiftool -compression  eudem_dem_3035_europe.tif
> Compression                     : Adobe Deflate

exiftool -compression CLMS_CLCplus_RASTER_2018_010m_eu_03035_V1_1.tif
> Compression                     : LZW
1
  • This is the sole option that works for me. Thank you. Commented May 16 at 14:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .