Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 8 Photos framework. Access photo metadata

I'm looking at replacing ALAssetsLibrary with Photos framework in my app.

I can retrieve photos, collections, and asset sources just fine (even write them back out), but don't see anywhere to access the metadata of the photos (the dictionaries such as {Exif}, {TIFF}, {GPS}, etc...).

ALAssetsLibrary has a way. UIImagePickerController has a way. Photos must have a way too.

I see that PHAsset has a location property which will do for the GPS dictionary, but I'm looking to access all of the metadata which include faces, orientation, exposure, ISO, and tons more.

Currently apple is at beta 2. Perhaps there are more APIs to come ?

UPDATE

There is no official way to do this using only Photos APIs.

However you can read the metadata after you download the image data. There are a couple of methods to do this using either PHImageManager or PHContentEditingInput.

The PHContentEditingInput method required less code and doesn't require you to import ImageIO. I've wrapped it up in a PHAsset category.

like image 235
VaporwareWolf Avatar asked Jun 27 '14 23:06

VaporwareWolf


People also ask

How do I view metadata on iOS Photos?

Locate and long-press the saved photo to invoke the contextual menu. Here tap info from the menu. On the Information page, tap Show More and scroll down to see detailed metadata. Once satisfied, tap Done.

How do I extract metadata from iPhone Photos?

Open the Photos app and tap an image in your Library. Tap the info button (the encircled "i" icon) below the image. Look for the EXIF data in the box below the date and time.

How do I see photo details in iOS?

1. In the Photos app, navigate to the photo you want to adjust. 2. Now, either swipe up on the photo or tap the info (i) button to view the photo's information.

How do you access photo information?

Follow these steps to view EXIF data on your Android smartphone. Open Google Photos on the phone - install it if needed. Open any photo and tap the i icon. This will show you all the EXIF data you need.


1 Answers

If you request a content editing input, you can get the full image as a CIImage, and CIImage has a property titled properties which is a dictionary containing the image metadata.

Sample Swift Code:

let options = PHContentEditingInputRequestOptions() options.networkAccessAllowed = true //download asset metadata from iCloud if needed  asset.requestContentEditingInputWithOptions(options) { (contentEditingInput: PHContentEditingInput?, _) -> Void in     let fullImage = CIImage(contentsOfURL: contentEditingInput!.fullSizeImageURL)      print(fullImage.properties) } 

Sample Objective-C Code:

PHContentEditingInputRequestOptions *options = [[PHContentEditingInputRequestOptions alloc] init]; options.networkAccessAllowed = YES; //download asset metadata from iCloud if needed  [asset requestContentEditingInputWithOptions:options completionHandler:^(PHContentEditingInput *contentEditingInput, NSDictionary *info) {     CIImage *fullImage = [CIImage imageWithContentsOfURL:contentEditingInput.fullSizeImageURL];      NSLog(@"%@", fullImage.properties.description); }]; 

You'll get the desired {Exif}, {TIFF}, {GPS}, etc dictionaries.

like image 51
Jordan H Avatar answered Sep 22 '22 19:09

Jordan H