Determining the image compression algorithm used on TIFF images

11

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.

klijo

Posted 2012-03-20T13:50:44.773

Reputation: 239

1Looking at the image's extension should be enough. – Icarus – 2012-03-20T13:52:23.790

isn't the extension a sufficient information? else, file gives you the basic infos on a file (linux/macosx) – None – 2012-03-20T13:52:40.893

1Most 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 – 2012-03-20T13:53:25.677

Answers

13

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

Zac B

Posted 2012-03-20T13:50:44.773

Reputation: 2 653

3

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.

W_Whalley

Posted 2012-03-20T13:50:44.773

Reputation: 3 212

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 – 2017-01-26T09:12:39.537

1

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

Adam Eberlin

Posted 2012-03-20T13:50:44.773

Reputation: 202

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 – 2017-05-27T18:02:52.057

But where is the name of the algorithm used ? – klijo – 2012-03-20T14:49:24.317

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 – 2012-03-20T15:04:22.697

2TIFF 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 – 2012-03-20T15:14:50.883

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 – 2012-03-20T15:16:50.123

@ZacB actually TIFF format is also there in the folder that iam inspecting. – klijo – 2012-03-20T15:18:34.827

2Use 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 – 2012-03-20T17:21:42.400

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 – 2012-03-21T13:06:57.120