亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

請問UIImagePickerController并從現有照片中提取EXIF數據

請問UIImagePickerController并從現有照片中提取EXIF數據

iOS
滄海一幻覺 2019-09-04 09:04:59
UIImagePickerController并從現有照片中提取EXIF數據眾所周知,UIImagePickerController在選擇后不會返回照片的元數據。但是,應用程序商店中的一些應用程序(Mobile Fotos,PixelPipe)似乎能夠讀取原始文件和存儲在其中的EXIF數據,使應用程序能夠從所選照片中提取地理數據。他們似乎是通過從/ private / var / mobile / Media / DCIM / 100APPLE /文件夾中讀取原始文件并通過EXIF庫運行它來完成此操作。但是,我無法找到一種方法來匹配從UIImagePickerController返回的照片到磁盤上的文件。我已經探索了文件大小,但原始文件是JPEG,而返回的圖像是原始UIImage,因此無法知道所選圖像的文件大小。我正在考慮制作一個哈希表并匹配每個圖像的前x個像素。雖然這看起來有點過頭了,但可能很慢。有什么建議?
查看完整描述

3 回答

?
手掌心

TA貢獻1942條經驗 獲得超3個贊

這適用于iOS5(beta 4)和相機膠卷(你需要為.h中的塊輸入defs):

-(void) imagePickerController:(UIImagePickerController *)picker 
           didFinishPickingMediaWithInfo:(NSDictionary *)info{
  NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
  if ([mediaType isEqualToString:(NSString*)kUTTypeImage]) {
    NSURL *url = [info objectForKey:UIImagePickerControllerReferenceURL];
    if (url) {
      ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset) {
      CLLocation *location = [myasset valueForProperty:ALAssetPropertyLocation];
      // location contains lat/long, timestamp, etc
      // extracting the image is more tricky and 5.x beta ALAssetRepresentation has bugs!
    };
    ALAssetsLibraryAccessFailureBlock failureblock = ^(NSError *myerror) {
      NSLog(@"cant get image - %@", [myerror localizedDescription]);
    };
    ALAssetsLibrary *assetsLib = [[ALAssetsLibrary alloc] init];
    [assetsLib assetForURL:url resultBlock:resultblock failureBlock:failureblock];
  }}



查看完整回答
反對 回復 2019-09-05
?
縹緲止盈

TA貢獻2041條經驗 獲得超4個贊

有一種方法 iOS 8

不使用任何第三方EXIF庫。

#import <Photos/Photos.h>- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

    NSURL *url = [info objectForKey:UIImagePickerControllerReferenceURL];
    PHFetchResult *fetchResult = [PHAsset fetchAssetsWithALAssetURLs:@[url] options:nil];
    PHAsset *asset = fetchResult.firstObject;

    //All you need is
    //asset.location.coordinate.latitude
    //asset.location.coordinate.longitude

    //Other useful properties of PHAsset
    //asset.favorite
    //asset.modificationDate
    //asset.creationDate}



查看完整回答
反對 回復 2019-09-05
  • 3 回答
  • 0 關注
  • 512 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號