Page 1 of 1

Converting TIF image twice produces different image files

Posted: 2006-12-16T14:38:29-07:00
by rmagick
Below is a script that takes an input TIFF image and does a "no-op" conversion to TIFF. It then takes the output image and performs the same conversion. It does this 10 times. Each output image file is slightly different, having a different signature, different number of colors, different IPTC profile, etc.

Is this caused by some inherent property of TIFF or am I overlooking something?

Code: Select all

#! /bin/bash 

COUNTER=0
INPUT=input
while [ $COUNTER -lt 10 ]
do
	convert ${INPUT}.tif output${COUNTER}.tif
	md5 output${COUNTER}.tif
	INPUT=output${COUNTER}
	COUNTER=`expr $COUNTER + 1`
done
If it makes a difference I can supply the input image. I'm running my tests with
Version: ImageMagick 6.3.1 12/11/06 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2007 ImageMagick Studio LLC
on OS X 10.4.8

Posted: 2006-12-16T17:22:18-07:00
by magick
Post a URL to your image. In our test we did get a different MD5 but that can be expected since some internal data may change each time the TIFF is written. However we used the compare program and in our tests each output image was exactly the same on a pixel-by-pixel basis.

Test image

Posted: 2006-12-17T07:55:02-07:00
by rmagick
Thanks for your help! Here's the input image.

http://rubyforge.org/tracker/download.p ... /input.tif

Posted: 2006-12-19T09:33:38-07:00
by rmagick
Were you able to get to the image I referred to in the previous post?

Posted: 2006-12-19T10:50:42-07:00
by magick
Your image is JPEG compressed which is a lossy compression algorithm. Some differences are expected when saving images with JPEG compression. Add -compress lzw to your command line and the compare program returns a MSE of 0 as expected for each iteration.

Posted: 2006-12-19T11:15:43-07:00
by rmagick
Thanks! I knew it was something peculiar to the image.

Posted: 2006-12-19T19:31:46-07:00
by anthony
Also as JPG compression was used, loading and saving multiple times using that compression would degrad the image. Best to avoid it if you can, though it will be a lot larger.