Identify to detect corrupted image file

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
al3x

Identify to detect corrupted image file

Post by al3x »

Hi !

I'm looking how to use identify to detect corrupted image file. I call identify with php so I need it returns something (short) I could handle with php.

I have tried that to check if the format is known :

Code: Select all

identify -format "%m"
But when a JPEG file is not complete because FTP transfert has failed for example, it returns 'JPEG' so i can't know the file is corrupted

Thank you !
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Identify to detect corrupted image file

Post by snibgo »

Code: Select all

convert infile NULL:
returns 0 on success, 1 on failure (eg if the file can't be converted).
snibgo's IM pages: im.snibgo.com
al3x

Re: Identify to detect corrupted image file

Post by al3x »

Thank you, Sounds good , I'll give it a try !
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Identify to detect corrupted image file

Post by snibgo »

Thinking further, I think the docs say other non-zero values are possible on failure.
snibgo's IM pages: im.snibgo.com
Post Reply