Detecting bad jpeg images
- by Gerard Cerchio
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?