i saved an image pulled from image picker into a mysql database, i retrieve the image and try to create a uiimage from it with
[self.currentPicView setImage:[[UIImage alloc] initWithData:[[Person person] current_pic]]];
and it gives me the error:
<Error>: ImageIO: PNG [5C][30][0D]I: invalid chunk type
<Error>: ImageIO: PNG [5C][30][0D]I: invalid chunk type
without crashing.. the image just doesn't show. i have no idea what that error means or how to fix it. any ideas?
ps:
[[Person person] current_pic]
contains the PNG image data.. Person is a singleton. current_pic is an NSData property in Person. i can't include that code because the property is synthesized and so i didn't create the method myself or override it.
To prep and upload(via POST using EPUpload from here ) the image, i do:
-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *image= [info objectForKey:@"UIImagePickerControllerOriginalImage"];
NSData *webData = UIImagePNGRepresentation(image);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *localFilePath = [documentsDirectory stringByAppendingPathComponent:@"temp-file"];
[webData writeToFile:localFilePath atomically:YES];
NSLog(@"localFilePath.%@",localFilePath);
[self doUpload:localFilePath];
[[picker parentViewController] dismissViewControllerAnimated:YES completion:^{}];
}
UPDATE: When i construct a UIImage in the didFinishPickingMedia method using 'webData', it doesn't give an error and the image is create sans error.
i tried uploading that same webData directly to the server with POST, then retrieved it and attempted to create another image from it, and got the error again
I got this issue when I had two png images in my bundle with the same name! orange.png
and orange.png
... renamed the second to citrus.png
, I hadn't even realized they had the same name for at least an hour, and whenever I would try to load that image, the app would crash with this error.
通过将其作为Base64String与服务器之间来回发送,可以避免这些错误
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.