IOS get File (UIImage) creation time

Source: Internet
Author: User

Image on the phone if it's a cell phone, you can use alassetslibrary to get the information color, GPS, size, creation date, etc. of a series of images

Importing a frame assetslibrary.framework using alassetslibrary to introduce a header file

#import <AssetsLibrary/AssetsLibrary.h>

Take the phone album for example code as follows: (get GPS inside timestamp for example)

#pragma-mark Uiimagepickercontroller delegate-(void) Imagepickercontroller: (Uiimagepickercontroller *) Picker Didfinishpickingmediawithinfo: (NSDictionary *) info{Chosenimage= [Info objectforkey:@"Uiimagepickercontrolleroriginalimage"]; //Specifying callback Methods[Picker dismissviewcontrolleranimated:yes completion:null]; Nsurl*asseturl =[Info Objectforkey:uiimagepickercontrollerreferenceurl]; Alassetslibrary*library =[[Alassetslibrary alloc] init]; [Library Assetforurl:asseturl Resultblock:^ (Alasset *Asset) {Nsdictionary* Imagemetadata =[[Nsmutabledictionary alloc] initWithDictionary:asset.defaultRepresentation.metadata]; Nsdictionary*gpsdict=[imagemetadata Objectforkey:@"{GPS}"]; NSLog (@"Time: datestamp:%@", [Gpsdict Objectforkey:@"Datestamp"]); } Failureblock:^ (Nserror *error)   {                 }]; }

When the photos and the phone are synced on the phone, I find that there is no information about the creation date or GPs in the dictionary.

I found a way. As long as the picture of the phone, you can get the image creation date method. Other relevant information will be used later to dig deeper.

Nsurl *asseturl = [info objectforkey:uiimagepickercontrollerreferenceurl];         *library = [[Alassetslibrary alloc] init];        [Library Assetforurl:asseturl                 Resultblock:^ (Alasset *asset) {                     nsdate* date = [asset Valueforproperty:alassetpropertydate];                     NSLog (@ "date:%@", date);                 }                 Failureblock:^ (nserror *error) {                 }];

Second, when the picture in the file form in the sandbox, the main is based on the file path to solve

IOS get File (UIImage) creation time

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.