identify doesn't detect corrupt JPEG files (Firefox does)
Posted: 2011-12-22T03:26:10-07:00
I wrote a little script to scan my photo collection / backups for errors using "identify" ("reports if an image is incomplete or corrupt"). Unfortunately it doesn't work. I tested it by null-bombing an image file using dd. (I repeated this a couple of times with different settings).
Identify doesn't notice the corruption:
Here's my version information:
But if I use Firefox instead, the corruption is detected correctly:
Code: Select all
dd conv=notrunc seek=30 count=1 if=/dev/zero of=test.jpg
Code: Select all
$ identify test.jpg
test.jpg JPEG 3409x2392 3409x2392+0+0 8-bit DirectClass 1.216MB 0.000u 0:00.000
$ echo $?
0
Code: Select all
# libjpeg package has the version number "6b-15ubuntu1"
$ identify --version # (compiled from source)
Version: ImageMagick 6.7.1-10 2011-08-25 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP
$ ldd `which identify`
linux-vdso.so.1 => (0x00007fff839ff000)
libMagickCore.so.4 => /usr/local/lib/libMagickCore.so.4 (0x00007ffd64e9a000)
libMagickWand.so.4 => /usr/local/lib/libMagickWand.so.4 (0x00007ffd64baa000)
libtiff.so.4 => /usr/lib/libtiff.so.4 (0x00007ffd64947000)
libc.so.6 => /lib/libc.so.6 (0x00007ffd645c4000)
libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0x00007ffd643a0000)
libpng12.so.0 => /lib/libpng12.so.0 (0x00007ffd64178000)
libz.so.1 => /lib/libz.so.1 (0x00007ffd63f61000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00007ffd63d44000)
libltdl.so.7 => /usr/lib/libltdl.so.7 (0x00007ffd63b39000)
libdl.so.2 => /lib/libdl.so.2 (0x00007ffd63935000)
libgomp.so.1 => /usr/lib/libgomp.so.1 (0x00007ffd63727000)
libm.so.6 => /lib/libm.so.6 (0x00007ffd634a3000)
/lib64/ld-linux-x86-64.so.2 (0x00007ffd6542d000)
librt.so.1 => /lib/librt.so.1 (0x00007ffd6329b000
But if I use Firefox instead, the corruption is detected correctly:
Code: Select all
$ firefox "/home/jenkins-photos/1925 - 2009 Ken/1993 Young Alice 'helping' Grandad.jpg"
Corrupt JPEG data: premature end of data segment
Corrupt JPEG data: premature end of data segment