IOS Error :( Error): ImageIO: png idat: invalid stored block lengths
Solution:
1. Read the image data and call the method in step 2 for verification.
NSData * data = [NSData dataWithContentsOfFile: imagePath];
2. Determine whether a PNG image is valid. For JPG images, use the UIImageJPEGRepresentation method.
/*** Verify whether the image is a valid PNG Image ** @ param imageData the NSData object obtained directly from the image file ** @ return whether it is a valid PNG Image */-(BOOL) isValidPNGByImageData :( NSData *) imageData {UIImage * image = [UIImage imageWithData: imageData]; // first case: When an image is directly generated through [UIImage imageWithData: data, if the image is nil, The imageData must be invalid if (image = nil & imageData! = Nil) {return NO;} // The second case: some of the images are OK, but some are broken. It will pass the first verification, you need to use the following method. Convert the image to PNG data. If the PNG data can be correctly generated, the image is complete and OK. If not, the image is damaged. NSData * tempData = UIImagePNGRepresentation (image ); if (tempData = nil) {return NO;} else {return YES ;}}