Page 1 of 1

Identify to detect corrupted image file

Posted: 2010-06-02T03:07:44-07:00
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 !

Re: Identify to detect corrupted image file

Posted: 2010-06-02T05:46:31-07:00
by snibgo

Code: Select all

convert infile NULL:
returns 0 on success, 1 on failure (eg if the file can't be converted).

Re: Identify to detect corrupted image file

Posted: 2010-06-02T06:16:21-07:00
by al3x
Thank you, Sounds good , I'll give it a try !

Re: Identify to detect corrupted image file

Posted: 2010-06-02T06:59:24-07:00
by snibgo
Thinking further, I think the docs say other non-zero values are possible on failure.