I have a harddisk which is maybe a little bit broken or not. The partition contains images only, especially, pef, arw and jpg-files with xml-files. I do not care about xml-files, but the image files are important. Is there a way to use exiftool to check for broken images? If this is important, I use Ubuntu and if I know how to check with exiftool I can put this in a bash-script. I have already used rsync to put everything on another hd.
You could try the experimental -validate feature to see how it goes with your files:
exiftool -validate DIR
- Phil
I use jpegtran to check for image corruption in jpegs. This is my bat file for windows that adds a keyword to the corrupt images. Something for Ubuntu probably wouldn't be hard to work up.
echo off
set Full=%*
set Full=%Full:"=%
for /f "delims=" %%i in ('dir /b /s "%Full%\*.jpg"') do (
echo Checking %%i
"C:\Programs\UnixUtils\libjpeg-turbo64\bin\jpegtran.exe" -outfile nul: "%%i" || (
exiftool -P -overwrite_original -mykeywords+="Corrupt Jpeg" "%%i"
)
)
Thank you for pointing me to jpegtran, but I think over 95% are rawfiles.
In the FAQ jhove was mentioned.
I did a test and loaded a valid dng-file in vi and put some characters in it and named it broken. Here is the result.
$ exiftool -ver
10.55
$ exiftool -validate ok.dng
Validate : 2 Warnings
So what does this tell me please? Can it be more verbose?
$ exiftool -validate broken.dng
Validate : 4 Warnings
2 warnings more, but what are these warnings?
$ jhove broken.dng
Jhove (Rel. 1.6, 2011-01-04)
Date: 2017-06-07 12:55:16 MESZ
RepresentationInformation: broken.dng
ReportingModule: BYTESTREAM, Rel. 1.3 (2007-04-10)
LastModified: 2017-06-07 12:51:33 MESZ
Size: 31942093
Format: bytestream
Status: Well-Formed and valid
SignatureMatches:
TIFF-hul
MIMEtype: application/octet-stream
jhove ok.dng shows all the metadata.
Any idea how I can decide if an image could be broken? More than 2 warnings with exiftool -validate?
Quote from: linuxuser on June 07, 2017, 07:03:47 AM
2 warnings more, but what are these warnings?
Add
-a -warning to the command to see all of the warnings. Some are more significant than others.
- Phil
exiftool -a -warning -validate ok.dng
Warning : Wrong IFD for 0x014a A100DataOffset (should be ExifIFD not IFD0)
Warning : Wrong IFD for 0xc617 CFALayout (should be ExifIFD not SubIFD)
Validate : 2 Warnings
exiftool -a -warning -validate broken.dng
Warning : Wrong IFD for 0x014a A100DataOffset (should be ExifIFD not IFD0)
Warning : Bad format (34304) for SubIFD entry 0
Warning : Bad format (32000) for SubIFD1 entry 0
Warning : Bad format (1280) for ExifIFD entry 0
Validate : 4 Warnings
Thanks Phil, actually I don't know if this is a realistic test szenario to put some signs in the image somewhere. If I try to open broken.dng I see a small preview, with ok.dng I see full size.
I tried a PEF-file, same procedure with vim inserting a few signs somewhere. Geequie shows with the broken file the preview only.
exiftool -a -warning -validate ok.pef
Validate : OK
exiftool -a -warning -validate broken.pef
Validate : OK
exiftool says it is fine.
At the first sight the jhove output looks fine, at least for me, I mean I see metadata.
jhove broken.pef | grep -i Error
ErrorMessage: PhotometricInterpretation not defined
ErrorMessage: Neither strips nor tiles defined
ErrorMessage: JPEGProc not defined for JPEG compression
ErrorMessage: PhotometricInterpretation not defined
ErrorMessage: Neither strips nor tiles defined
ErrorMessage: JPEGProc not defined for JPEG compression
OK. The "Bad format" errors are significant and indicate a corrupted IFD.
The "Wrong IFD" warnings you can ignore -- these warnings are not yet reliable.
- Phil
Thanks Phil, but broken.pef doesn't report an error with exiftool.
There are places you can change the file that are not detectable unless you actually develop and view the RAW data by eye.
Even if you tamper with the metadata, you will only get errors part of the time, as you have seen. To understand this, I recommend using the -htmldump feature to get a feel for the structure of the file.
But disk errors tend to corrupt enough to cause rather severe problems, so generally these are easier to detect.
- Phil
I was also doing this and quickly found a few files with
Validate : 1 Warning
Warning : JPEG format error
which I could delete.
but I think it would be reasonable (and conform to the standards) to not use the exit code of 0 in this case.
other programs (like grep) use a non zero exit code when there are no errors but when an assertion fails (like no lines match).
Quote from: elatllat on July 08, 2017, 08:40:55 PM
but I think it would be reasonable (and conform to the standards) to not use the exit code of 0 in this case.
other programs (like grep) use a non zero exit code when there are no errors but when an assertion fails (like no lines match).
That it doesn't return a non-zero return code here is because there is no errror, just a warning...
Hmm, perhaps with validate these should be treated as error?
How about this?
exiftool -if 'not $warning' -validate ...
This will exit with 0 only if the file didn't have any warnings.
- Phil