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