How to test if an image file is corrupt

Is it possible to test if an image file is corrupt… meaning it won’t be displayed by display.newImage or display.newImageRect? I’m displaying files uploaded by users on a website of mine and have run across some invalid jpg files I’d like to be able to test.

Thanks [import]uid: 98617 topic_id: 28929 reply_id: 328929[/import]

I’m not certain on this but I would think it would be easier to check the imagine when it is uploaded to your website rather than downloading it to the app first. [import]uid: 52491 topic_id: 28929 reply_id: 116493[/import]

If you mean a valid image, as in one that is there vs one that isn’t there, here’s a solution:
http://developer.coronalabs.com/forum/2012/07/14/detect-if-reliable-image

If you mean one that’s an image but can’t be displayed, I don’t know.

binc [import]uid: 147322 topic_id: 28929 reply_id: 116538[/import]

Thanks. It’s the second option… the file exists but is damaged and can’t be displayed. [import]uid: 98617 topic_id: 28929 reply_id: 116584[/import]

You might try peach’s example, and monitor all of the images that are uploaded.

I’ve just tried to figure out a way to tell if it’s corrupt (I opened an image file with TextEdit and added an extra character), but it’s still saying it displayed it, only it’s giving me an error in the terminal. If you could check the terminal from your app, you might be able to (just a wild guess?), and then see if it had written an error.

You probably can’t do that, though.

binc [import]uid: 147322 topic_id: 28929 reply_id: 116589[/import]