ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: qliu on October 08, 2019, 04:12:12 PM

Title: Mimetype detection error message
Post by: qliu on October 08, 2019, 04:12:12 PM
Hi,

I'm using exiftool to do file detection to filter out invalid files. I am confused with the error messages on the command line exiftool -mimetype -b filename. For example, for a TGA file I got this: Error: Unknown file type - XXX.TGA. For a CRW file, I got this: Error: File format error - XXX.CRW.

Can you help to clarify what this means and would there be some other error messages? I hope to know which one means the file is broken, and which one means exiftool failed but file could be good. Thanks!
Title: Re: Mimetype detection error message
Post by: StarGeek on October 08, 2019, 04:38:27 PM
In the first case, the file is probably so badly damaged that exiftool can't find any data that would normally identify it as a TGA file.  In the second case, there seems to be enough data that it starts to try and figure out what the file is, but again, it's too corrupt to proceed.  Are either of these files able to be viewed?

Just my guesses, Phil will be able to give more details.

Also, is there any specific reason you're including the -b (binary) option (https://exiftool.org/exiftool_pod.html#b--binary)?  It doesn't seem that it would be useful if you're just getting the mime type.
Title: Re: Mimetype detection error message
Post by: Phil Harvey on October 08, 2019, 05:38:17 PM
Quote from: StarGeek on October 08, 2019, 04:38:27 PM
In the first case, the file is probably so badly damaged that exiftool can't find any data that would normally identify it as a TGA file.  In the second case, there seems to be enough data that it starts to try and figure out what the file is, but again, it's too corrupt to proceed.

Exactly.
Title: Re: Mimetype detection error message
Post by: qliu on October 08, 2019, 08:08:21 PM
Quote from: StarGeek on October 08, 2019, 04:38:27 PM
In the first case, the file is probably so badly damaged that exiftool can't find any data that would normally identify it as a TGA file.  In the second case, there seems to be enough data that it starts to try and figure out what the file is, but again, it's too corrupt to proceed.  Are either of these files able to be viewed?

Just my guesses, Phil will be able to give more details.

Also, is there any specific reason you're including the -b (binary) option (https://exiftool.org/exiftool_pod.html#b--binary)?  It doesn't seem that it would be useful if you're just getting the mime type.

Thanks for the info. The TGA file looks good on my mac, the second CRW file could be corrupted but i'm able to see it use ImageMagick. The -b could be unnecessary I guess, it just shows the result in a brief way.

For mimetype failures, is there any way to differentiate these: blame the file or exiftool corrupt in the middle? Even though exiftool looks pretty stable to me, I have to add some timeout mechanism in my code which could stop exiftool from running. What would be the error message in that case? Thanks
Title: Re: Mimetype detection error message
Post by: StarGeek on October 08, 2019, 09:41:11 PM
Quote from: qliu on October 08, 2019, 08:08:21 PM
The -b could be unnecessary I guess, it just shows the result in a brief way.

Try the -s (short) option (https://exiftool.org/exiftool_pod.html#s-NUM--short), specifically -s3.  It'll do what you want without the chance of unintended junk output.
Title: Re: Mimetype detection error message
Post by: Phil Harvey on October 08, 2019, 09:51:39 PM
ExifTool doesn't support TGA files.  Use exiftool -listf for a list of supported file file types.

If you prematurely stop ExifTool from running you won't get an error message.

- Phil
Title: Re: Mimetype detection error message
Post by: qliu on October 09, 2019, 02:16:46 PM
Thanks! Would the exit code be different for all these possible failure reasons? Or if all the error messages in this pattern Error: (.*) - filename so that I can parse them?
Title: Re: Mimetype detection error message
Post by: Phil Harvey on October 09, 2019, 07:33:32 PM
That pattern should work for all errors that I can think of.

- Phil