iOS error: <error>: imageio:png idat:invalid stored block lengths

Source: Internet
Author: User

Workaround:

1. Read the picture data, and then call the method in 2 to verify

NSData* data = [NSData dataWithContentsOfFile:imagePath];

2. Determine if a valid PNG image, JPG, use the UIImageJPEGRepresentation method

/** * Verify that the picture is a valid PNG image * * @param imageData image file directly get the NSData object * * @return is a valid PNG picture */- (BOOL) Isvalidpngbyimagedata: (NSData*) imagedata{UIImage* image = [UIImageImagewithdata:imagedata];///First case: by [UIImage imagewithdata:data]; If image is nil, then ImageData must be invalid    if(Image = =Nil&& ImageData! =Nil) {return NO; }///second situation: The picture is OK, but part of it is broken, it will pass the first step verification, then the following method is necessary. Convert the image to PNG data, if the PNG data can be generated correctly, then this picture is complete OK, if not, then the picture is damaged    NSData* TempData = uiimagepngrepresentation (image);if(TempData = =Nil) {return NO; }Else{return YES; }}


iOS error: <error>: imageio:png idat:invalid stored block lengths

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.