Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to know this image is jpg or png iphone

i will like to pick an images from UIImagepicker, there are PNG and JPG format in camera roll.

and i need to convert it into NSData. However i need to know if this images is UIImageJPEGRepresentation or UIImagePNGRepresentation so i could convert it.

UIImage *orginalImage = [info objectForKey:UIImagePickerControllerOriginalImage];    
    [picker dismissViewControllerAnimated:YES completion:nil];
    NSData *orgData = UIImagePNGRepresentation(orginalImage);
like image 297
Desmond Avatar asked Apr 20 '12 02:04

Desmond


1 Answers

You shouldn't know or care what the internal representation of images in the camera roll is. The methods you mentioned UIImageJPEGRepresentation and UIImagePNGRepresentation return you representations of the camera roll image. It's up to you to pick which representation you want to use.

To summarize:

NSData * pngData = UIImagePNGRepresentation(originalImage);

Will return you the image representation in an NSData object, with the format PNG.

like image 81
Perception Avatar answered Oct 21 '22 09:10

Perception