ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Gnarlodious on October 17, 2010, 08:46:45 AM

Title: Error: Format error in file
Post by: Gnarlodious on October 17, 2010, 08:46:45 AM
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?
Title: Re: Error: Format error in file
Post by: Phil Harvey on October 17, 2010, 12:20:54 PM
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
Title: Re: Error: Format error in file
Post by: Phil Harvey on October 18, 2010, 07:04:43 AM
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
Title: Re: Error: Format error in file
Post by: Phil Harvey on October 18, 2010, 07:39:25 AM
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
Title: Re: Error: Format error in file
Post by: Gnarlodious on October 18, 2010, 11:04:56 AM
Thank you, that will help.
Title: Re: Error: Format error in file
Post by: khoai_dao on January 03, 2015, 09:15:13 AM
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 (https://drive.google.com/file/d/0B5ipW1w36t93VXctMmlJbW96dGc/view?usp=sharing)
Many thanks,
Title: Re: Error: Format error in file
Post by: Phil Harvey on January 03, 2015, 12:26:12 PM
I'll be able to download the file on monday, so I'll take a look at it then.

- Phil
Title: Re: Error: Format error in file
Post by: khoai_dao on January 04, 2015, 05:51:21 AM
Thanks Phil very much!
Title: Re: Error: Format error in file
Post by: Phil Harvey on January 05, 2015, 06:54:34 AM
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 (https://exiftool.org/forum/index.php/topic,4172.msg19805.html#msg19805)) to extract this preview image.

- Phil