convert somewhat non-deterministic...?
Posted: 2009-11-22T18:47:35-07:00
I'm having problems with a script using convert. It used to work reliably, but now it doesn't. The output from convert is unpredictable and seemingly somewhat non-deterministic. Here's the important line:
That's converting an image to a 8x8 monochrome version of itself, in text form, which is then manipulated and fed into bc to get a 64-bit value to serve as the image's "fingerprint" in a database.
Previously, scaled versions of the same image reliably produced exactly the same output. Now they don't. Even more frustrating, the same file might on one execution produce one output, and on another execution produce a totally different output. This happens even with lossless image formats, although it seems to happen more with lossy ones. (One .png I have will reliably produce one of two outputs; a .jpg version of the same file produces many different outputs, some of them repeating, some seemingly random.)
I'm running Kubuntu 9.10.
Code: Select all
pname_base=`/usr/bin/convert "$fname" -scale 8x8! -monochrome text:- | tail -n 64 | cut -c 30 | tr -d '\n' | tr 'w' '1' | tr 'b' '0' | sed 's/^/ibase=2; /' | sed 's/$/\n/' | bc`;
Previously, scaled versions of the same image reliably produced exactly the same output. Now they don't. Even more frustrating, the same file might on one execution produce one output, and on another execution produce a totally different output. This happens even with lossless image formats, although it seems to happen more with lossy ones. (One .png I have will reliably produce one of two outputs; a .jpg version of the same file produces many different outputs, some of them repeating, some seemingly random.)
Code: Select all
kevin@aphrodite:~$ convert -version
Version: ImageMagick 6.5.1-0 2009-08-27 Q16 OpenMP http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC