Mimetype detection error message

Started by qliu, October 08, 2019, 04:12:12 PM

Previous topic - Next topic

qliu

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!

StarGeek

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?  It doesn't seem that it would be useful if you're just getting the mime type.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

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.
...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 ($).

qliu

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?  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

StarGeek

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, specifically -s3.  It'll do what you want without the chance of unintended junk output.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

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
...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 ($).

qliu

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?

Phil Harvey

That pattern should work for all errors that I can think of.

- 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 ($).