15

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.

Pops
  • 8,473
klijo
  • 279
  • 1
    Looking at the image's extension should be enough. – Icarus Mar 20 '12 at 13:52
  • isn't the extension a sufficient information? else, file gives you the basic infos on a file (linux/macosx) –  Mar 20 '12 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 Mar 20 '12 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 Feb 06 '24 at 10:00

4 Answers4

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
Giacomo1968
  • 55,001
Zac B
  • 2,903
  • 4
  • 24
  • 39
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.

Giacomo1968
  • 55,001
W_Whalley
  • 3,492
  • 1
  • 19
  • 17
  • 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 Jan 26 '17 at 09: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
  • 1
    But where is the name of the algorithm used ? – klijo Mar 20 '12 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 Mar 20 '12 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 Mar 20 '12 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 Mar 20 '12 at 15:16
  • @ZacB actually TIFF format is also there in the folder that iam inspecting. – klijo Mar 20 '12 at 15:18
  • 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 Mar 20 '12 at 17:21
  • hi @Zac B could you answer my question with your suggestion. You saved me here because i really wanted a command line tool to do this, and i like to award you points for that. – klijo Mar 21 '12 at 13:06
  • Actually, file worked perfectly fine for me: TIFF image data, little-endian, direntries=26, height=5255, bps=326, compression=LZW, PhotometricIntepretation=RGB, description= , manufacturer=SONY, model=DSC-RX100, orientation=upper-left, width=15814! However, there are many different versions of file. – Daniel B May 27 '17 at 18:02
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
Giacomo1968
  • 55,001
Walty Yeung
  • 186
  • 1
  • 6
  • 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... :< – RokeJulianLockhart Feb 20 '24 at 18:29