Error: Format error in file

Started by Gnarlodious, October 17, 2010, 08:46:45 AM

Previous topic - Next topic

Gnarlodious

Hello. I have several thousand scanned images of historical value. I try to change the EXIF but all I get is this:

   Error: Format error in file - bad.jpg
   0 image files updated
   1 files weren't updated due to errors


What is wrong and how to fix it?

Phil Harvey

This sounds like a problem with the JPEG image itself, rather than a problem with the metadata.  If you send a sample to me (philharvey66 at gmail.com) I can give you a more informed answer.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

Thanks for the sample.  This is very interesting.  The problem is that the file is not a JPEG image.  Change the extension from JPG to TIF and all is well.

But I am surprised because exiftool should have recognized this as a TIF.  I'll look into this in more detail and figure out what is happening and post back here.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

I checked the code.  When reading, ExifTool will properly detect the file type, but when writing ExifTool currently uses the file extension as a sanity check to provide a tighter validation of the file format.  I don't want to relax this because it is safer this way, but I will change the error message to make this more obvious.  The next version will give this error when you try to rewrite your image:

Error: Not a JPEG file (looks more like a TIFF) - image.jpg


- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Gnarlodious


khoai_dao

#5
Dear Mr Phil,
I have a same CR2 error. I deleted my file, and after that I recoveried this file. Howerver, when I recoveried, my file can't be read. When I use Exiftool, this program report: File format error. Please tell me some tips, my files are very important to me!
File download: https://drive.google.com/file/d/0B5ipW1w36t93VXctMmlJbW96dGc/view?usp=sharing
Many thanks,

Phil Harvey

I'll be able to download the file on monday, so I'll take a look at it then.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

khoai_dao


Phil Harvey

This file contains valid data from a Canon CR2 image starting at offset 0x558000 in the file.  Unfortunately, the raw image data is truncated, but the 5760x3840 JPG preview is intact.  You can use my extract_preview script (see this post) to extract this preview image.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).