In order to test if LZW compression is truly lossless I did the following:

  1. I created a master uncompressed TIFF file.
  2. Created an LZW compressed version of it
  3. Saved that compressed TIFF back into an uncompressed TIFF.
  4. Finally compared the latter to the master TIFF with a hex editor.

The files appeared identical, except for one part where a single hex value was increased from 45 to 47 in the post-LZW version of the TIFF. I doubt this has any effect on the quality of the TIFF file, however, can someone explain what causes this to happen?

  • MikeFitzpatrick’s answer is the best explanation. While image data most likely did not change, metadata could have been altered or appended. I recommend double-checking with ExifTool which is an excellent EXIF metadata tool. Just compare the metadata output of both files and I am willing to bet some small bit of metadata was changed. Apr 4 '15 at 1:50

The process you have described should yield identical pixel data but the metadata (such as a timestamp) might be different.

The TIFF Specification defines how metadata and image data is arranged within TIFF files.

If you want to do a hex comparison then I suggest you convert both the TIFF files to a much simpler format (eg. PPM or Photoshop Raw) and compare those instead. That way, you're comparing the pixel data and not the pixel data + metadata.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy