How to Check if an image is valid
For example, when I cached an image which was downloaded only half and failed, and this image is invalid, then I want to know it’s an invalid image and download again.
(When I use the broken image, Xcode console logs an error:
ImageIO: PNG IDAT: CRC error )
So I want find a mechanism to check image’s validation
for different kinds of JPEG,PNG,etc
anybody has some clues?
I would start by checking for valid header.
Secondly the footer. Usually the last 8 bytes uint values in order are
‘73,69,78,68,174,66,96,130’.
This converted into a Int64 equals 5279712195050102914
This should do for a png 🙂