ios - How to get dpi/ppi of UIImage? -


how dpi/ppi of image in ios? maybe raw image file contains information, can ppi/dpi nsdata? thank you.

to extract dpi image stored in nsdata, include apple's imageio framework in project , use following:

#import <imageio/imageio.h>  // set nsdata nsdata *data = image data  // dpi of image cgimagesourceref imageref = cgimagesourcecreatewithdata((__bridge cfdataref)(data), null); cfdictionaryref imagepropertiesdict = cgimagesourcecopypropertiesatindex(imageref, 0, null); nsstring *dpiheight = cfdictionarygetvalue(imagepropertiesdict, @"dpiheight"); nsstring *dpiwidth = cfdictionarygetvalue(imagepropertiesdict, @"dpiwidth"); 

note not images contain dpi information. may or may not included in image's metadata.

this answer based upon flar49's answer, correct, enhanced information directly nsdata. see http://iosdevelopertips.com/data-file-management/get-image-data-including-depth-color-model-dpi-and-more.html more information.


Comments