Modifying and resizing tif images

Recently,  we had the need to resize some 8-bit greyscale tif images so that they took less space on disk. I had problems doing this since the app that wrote them in the first place used an old jpeg compression routine which was not compiled into the Ubuntu 10.10 tiff libraries.

I ended up installing the following in order on a Centos 5.5 VM. These were the latest releases as of this post.

jpg-8c (from www.ijg.org)

./configure –prefix=/usr –infodir=/usr/share/info –mandir=/usr/share/man

tiff-3.9.5 (from www.libtiff.org)

./configure –prefix=/usr –infodir=/usr/share/info –mandir=/usr/share/man –enable-jpeg –enable-old-jpeg

ImageMagick-6.7.0-9 (from www.imagemagick.org)

./configure –prefix=/usr –infodir=/usr/share/info –mandir=/usr/share/man

Once done, I finally found the best way to change the compression without ballooning the resulting file was to use:

convert 4527222.img -colorspace gray +dither -colors 8 -normalize -quality 75% 4527222.tif

( in this example, +dither actually disables dithering, -colors sets the palette to 8 bit and -quality sets jpeg compression to 75%)

This makes the file slightly smaller than the original, so to reduce it further, I used the downsize script from fwmconcepts

./downsize -s 100 4527222.tif 4527222-resize100.tif

Leave a Reply