I have a list of (.TIFF) files which I am renaming and saving in the same format. I am using cv2 module to do this.
import cv2
import os
import glob
os.chdir('C:/99_Temp/')
for file in glob.glob("*.tiff"):
f = os.path.splitext(file)
time_val = f[0][:2]
a1 = cv2.imread(file)
cv2.imwrite(time_val+'.tiff',a1)
Why are the file sizes reduced from the original TIFF file? I haven't done any processing and visually the images look the same. But I am wondering, why the difference?
There could be many explanations of why the size of a TIFF file changes. Here are a few:
one file may be RGB with 3 bytes of red, green and blue per pixel, while another encoder may see that the file has fewer than 256 colours and decide to write a single byte of palette index per pixel (and store the 256 colours in a separate palette) rather than 3 bytes of RGB.
one file may be 8-bit, the other may be 1-bit (bi-level), 16 bit, 32-bit or 64-bit.
the files may have different compression - varying through none, to LZW, RLE or more recently JPEG.
one coder may have written IPTC or other metadata, whilst the other discarded it.
one coder may have included a low resolution preview, the other not.
In order to check, you could use
exiftool
which is just a Perl script and simple and small to install:Sample Output
Or
tiffinfo
which comes withlibtiff
and is also pretty small and easy to install:Sample Output
Or ImageMagick which is installed on most Linux distros and is available for macOS and Windows - but is quite a large install:
Sample Output