Slight discrepancy with filecmp.cmp

Ivan Van Laningham ivanlan at pauahtun.org
Mon Apr 18 00:06:04 EDT 2005


Hi All--
I noticed recently that a few of the jpgs from my digital cameras have
developed bitrot.  Not a real problem, because the cameras are CD
Mavicas, and I can simply copy the original from the cd.  Except for the
fact that I've got nearly 25,000 images to check.  So I wrote a set of
programs to both index the disk versions with the cd versions, and to
compare, using filecmp.cmp(), the cd and disk version.  Works fine. 
Turned up several dozen files that had been inadvertantly rotated or
saved with the wrong quality, various fat-fingered mistakes like that.

However, it didn't flag the files that I know have bitrot.  I seem to
remember that diff uses a checksum algorithm on binary files, not a
byte-by-byte comparison.  Am I wrong?  If I am, what then is the source
of the problem in my jpg images where it looks like a bit or two has
been shifted or added; suddenly, there's a line going through the
picture above which it's normal, and below it either the color has
changed (usually to pinkish) or the remaining raster lines are all
shifted either right or left?

Any ideas?

Metta,
Ivan
----------------------------------------------
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours



More information about the Python-list mailing list