Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>Accessing image properties, such as image height and width, DPI, EXIF data, etc., via ImageIO</h2> <pre><code>CFURLRef url = CFURLCreateFromFileSystemRepresentation (kCFAllocatorDefault, (const UInt8 *)inputFileName, strlen(inputFileName), false); if (!url) { printf ("* * Bad input file path\n"); } CGImageSourceRef myImageSource; myImageSource = CGImageSourceCreateWithURL(url, NULL); CFDictionaryRef imagePropertiesDictionary; imagePropertiesDictionary = CGImageSourceCopyPropertiesAtIndex(myImageSource,0, NULL); CFNumberRef imageWidth = (CFNumberRef)CFDictionaryGetValue(imagePropertiesDictionary, kCGImagePropertyPixelWidth); CFNumberRef imageHeight = (CFNumberRef)CFDictionaryGetValue(imagePropertiesDictionary, kCGImagePropertyPixelHeight); int w = 0; int h = 0; CFNumberGetValue(imageWidth, kCFNumberIntType, &amp;w); CFNumberGetValue(imageHeight, kCFNumberIntType, &amp;h); CFRelease(imagePropertiesDictionary); CFRelease(myImageSource); printf("Image Width: %d\n",w); printf("Image Height: %d\n",h); </code></pre> <p>( source: <a href="http://developer.apple.com/library/ios/#qa/qa1654/_index.html" rel="noreferrer">http://developer.apple.com/library/ios/#qa/qa1654/_index.html</a> )</p> <pre><code> NSString *myPath = [[NSBundle mainBundle] pathForResource:@"IMG_2733" ofType:@"JPG"]; NSURL *myURL = [NSURL fileURLWithPath:myPath]; CGImageSourceRef mySourceRef = CGImageSourceCreateWithURL((CFURLRef)myURL, NULL); NSDictionary *myMetadata = (NSDictionary *) CGImageSourceCopyPropertiesAtIndex(mySourceRef,0,NULL); NSDictionary *exifDic = [myMetadata objectForKey:(NSString *)kCGImagePropertyExifDictionary]; NSDictionary *tiffDic = [myMetadata objectForKey:(NSString *)kCGImagePropertyTIFFDictionary]; NSLog(@"exifDic properties: %@", myMetadata); //all data float rawShutterSpeed = [[exifDic objectForKey:(NSString *)kCGImagePropertyExifExposureTime] floatValue]; int decShutterSpeed = (1 / rawShutterSpeed); NSLog(@"Camera %@",[tiffDic objectForKey:(NSString *)kCGImagePropertyTIFFModel]); NSLog(@"Focal Length %@mm",[exifDic objectForKey:(NSString *)kCGImagePropertyExifFocalLength]); NSLog(@"Shutter Speed %@", [NSString stringWithFormat:@"1/%d", decShutterSpeed]); NSLog(@"Aperture f/%@",[exifDic objectForKey:(NSString *)kCGImagePropertyExifFNumber]); NSNumber *ExifISOSpeed = [[exifDic objectForKey:(NSString*)kCGImagePropertyExifISOSpeedRatings] objectAtIndex:0]; NSLog(@"ISO %i",[ExifISOSpeed integerValue]); NSLog(@"Taken %@",[exifDic objectForKey:(NSString*)kCGImagePropertyExifDateTimeDigitized]); </code></pre> <p>( source: <a href="http://blog.depicus.com/index.php/2011/05/07/getting-exif-data-from-images-on-ios/" rel="noreferrer">http://blog.depicus.com/index.php/2011/05/07/getting-exif-data-from-images-on-ios/</a> )</p> <h2>Accessing EXIF properties via the open source (but outdated) iphone-exif library</h2> <pre><code>NSData* theImageData = UIImageRepresentation(anImage,1.0); EXFJpeg* jpegScanner = [[EXFJpeg alloc] init]; [jpegScanner scanImageData: theImageData]; EXFMetaData* exifData = jpegScanner.exifMetaData; EXFJFIF* jfif = jpegScanner.jfif; id tagValue = [exifData tagValue: aTagId]; </code></pre> <p>( source: <a href="http://code.google.com/p/iphone-exif/" rel="noreferrer">http://code.google.com/p/iphone-exif/</a> )</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload