0

I am trying to find out the DPI of the selected image from photo library but getting (null).

Using below code.

 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

UIImage *chosenImage = info[UIImagePickerControllerOriginalImage];
NSData * imgData = UIImageJPEGRepresentation(chosenImage, 0.0);
CGImageSourceRef src = CGImageSourceCreateWithData((CFDataRef) imgData, NULL);
CFDictionaryRef imageDict = CGImageSourceCopyPropertiesAtIndex(src, 0, NULL);

// Print image dictionary
NSString *dpiHeight = CFDictionaryGetValue(imageDict, @"DPIHeight");
NSString *dpiWidth = CFDictionaryGetValue(imageDict, @"DPIWidth");   
NSLog(@"DPIHeight:%@ DPIWidth: %@",dpiHeight, dpiWidth);

}

is it correct ? can i get DPI from image data ? is there any other possibilities ?

Can any one help me will highly appreciated.

Thank you.

Chandan Reddy
  • 221
  • 1
  • 5
  • 19

0 Answers0