Detecting bad jpeg images

Posted by Gerard Cerchio on Stack Overflow See other posts from Stack Overflow or by Gerard Cerchio
Published on 2009-07-31T01:47:13Z Indexed on 2010/03/18 0:01 UTC
Read the original article Hit count: 383

Filed under:
|

The question on validating jpegs on network transfer is very helpful.

Could we take this question one step further? What if the image data is incomplete or corrupt from the server? The complete transport works, the MIME type is image/jpeg, the UIImage is constructed and non-nil but the renderer discovers inconsistencies in the data and the log shows "Bad Huffman code" or "premature end of data segment"

How would I capture this error before tossing the UIImage into the view context and thereby getting a not-pretty image on the screen? Could I render it to a non-screen context and capture the error?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about iphone-sdk