4
\$\begingroup\$

From what I understand TIFF is like the .mkv container for photography - it supports a variety of compressed and uncompressed formats.

But how would you go about checking if the data within the TIFF file is indeed uncompressed? I'm worried it could just contain a lossy photo.

\$\endgroup\$
3
  • \$\begingroup\$ Even if the tiff you have is currently uncompressed that doesn't mean the data was never compressed :( \$\endgroup\$ Jun 7, 2019 at 1:33
  • \$\begingroup\$ Yes - was about to ask this. Is there any way to tell the underlying compression? \$\endgroup\$
    – Elie
    Jun 7, 2019 at 13:58
  • \$\begingroup\$ If the data was only ever losslessly compressed (LZW, Deflate), there is no way to know its compression history. If the data was compressed with lossy methods, such as JPEG, you could look for compression artifacts. For JPEG, these would fall along 8x8 or 16x16 block boundaries. There may also be signs of lost color information. \$\endgroup\$
    – xiota
    Jun 17, 2019 at 2:23

4 Answers 4

2
\$\begingroup\$

TIFF is a container format. Some other formats, such as DNG, are based on TIFF containers.

You can use exiftool to determine whether a TIF file contains compressed data.

usr@hst:/tmp$ exiftool -compression test1.tif 
Compression                     : Uncompressed
usr@hst:/tmp$ exiftool -compression test2.tif 
Compression                     : JPEG

Is this used to tell the current compression of the .tif file, or the compression of the data in the .tif file? – Elie

TIFFs are containers. Unless you put them into another container (zip), they themselves are not compressed. It's the (image) data contained within them that is compressed. Colloquially, when people say a file type is compressed (jpg), they mean the data within the file is compressed.

Even if the tiff you have is currently uncompressed that doesn't mean the data was never compressed :( – Peter Green

Is there any way to tell the underlying compression? – Elie

If the data was only ever losslessly compressed (LZW, Deflate), there is no way to know its compression history. If the data was compressed with lossy methods, such as JPEG, you could look for compression artifacts. For JPEG, these would fall along 8x8 or 16x16 block boundaries. There may also be signs of lost color information. The utility jpegjudge may be used to assess the quality of images saved as JPEG.

\$\endgroup\$
2
  • \$\begingroup\$ Is this used to tell the current compression of the .tif file, or the compression of the data in the .tif file? \$\endgroup\$
    – Elie
    Jun 7, 2019 at 13:59
  • \$\begingroup\$ TIFFs are containers. Unless you put them into another container (zip), they themselves are not compressed. It's the (image) data contained within them that is compressed. Colloquially, when people say a file type is compressed (jpg), they mean the data within the file is compressed. \$\endgroup\$
    – xiota
    Jun 7, 2019 at 14:16
1
\$\begingroup\$

If you are using a Linux or Unix-like system (including MacOS), you can use the file command that comes built-in to most Linux/Unix distributions. In a terminal:

scottbb@mbp ~/Downloads $ file CCITT_1.TIF
CCITT_1.TIF: TIFF image data, little-endian, direntries=17, height=2376, bps=1,
compression=bi-level group 4, PhotometricIntepretation=WhiteIsZero,
name=Standard Input, description=converted PBM file, orientation=upper-left, width=1728

The file command is a Swiss Army knife utility that will tell you all sorts of information about almost any file you throw at it.

\$\endgroup\$
1
\$\begingroup\$

If you have Photoshop it is easy to identify the type of file compression if any. Only JPEG compression, which is only available on 8 bit tif files, results in any image deterioration.

Open the tif file in Photoshop then select save as (though you won't actually be saving it). You will see this dialog.

Initial dialog

Now select save. This will not save but open up another dialog box.

Second dialog

All the settings shown are what the original tif image is stored as. You can change them here but the purpose is to determine the format of the original image.

The only thing of concern is if the image is in jpeg. This also means the image is 8 bits. Any other compression is not lossy and no image degradation can occur.

This is what will show for jpeg compressed tif files:

8 bit jpeg compression

Now cancel. You don't want to accidentally save it, just examine it's attributes.

\$\endgroup\$
0
\$\begingroup\$

But how would you go about checking if the TIFF file is indeed uncompressed?

A quick test.

Open your photo, and re-save it as TIF with another name, with no compression. Compare the file weight.

The file size of an uncompressed image will be about the same.

I'm worried it could just be a lossless container for a lossy photo.

It is a very specific case. It is not about compression, as your first inquiry, it is about lossy compression.

Make some additional tests with different compression methods. LZW or ZIP (both lossless)

If the file size is a lot smaller than those, it was probably saved using JPG compression, therefore lossy.

But the one and only exact test you can make is taking the original photo, overlay it using "difference" as blending mode, flatten it, and see the histogram. https://otake.com.mx/Apuntes/Imagen/PruebasDeCompresion/1-CompresionJpgProceso.phtm

But take into account that there is a big chance, the original photo was saved as JPG from start.


And yes, TIF format is very specific. I would not recommend it for normal photographers. I only would recommend it for specific cases:

  1. When you need a 16 bits per channel image and you can not send a PSD file.

  2. When you are saving a CMYK image, you do not want to use JPG and cannot send a PSD file.

  3. Some weird file, like a multi-channel file, CMYK and transparency, etc... and you can not send a PSD file.

And that is probably it.

\$\endgroup\$
2
  • \$\begingroup\$ Both Zip and LZW compression is lossless and these are the most common compressions used in tiff files. Photoshop only offers these lossless compression types in saving tiff files. Those tiff file apps that offer jpeg compression are lossy. \$\endgroup\$
    – doug
    Jun 7, 2019 at 5:21
  • \$\begingroup\$ @xiota, Jpeg compression can be used in Photoshop tiffs but only on 8 bit files but also brings up a compatibility warning re older Photoshops. It's grayed out on higher bit files. If you open a tiff file then hit "save as" it will show the same compression settings of the original file so that's one way to tell if a tiff file is using lossy compression. Almost all my work in tiff files is 16 bit and I don't think I've ever seen an 8 bit tiff file encoded in jpeg. Apparently it is now supported but wasn't in older Photoshops so I had it backwards. \$\endgroup\$
    – doug
    Jun 7, 2019 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.