UIImagePickerController并从现有照片中提取EXIF数据 [英] UIImagePickerController and extracting EXIF data from existing photos

查看:201
本文介绍了UIImagePickerController并从现有照片中提取EXIF数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

众所周知,UIImagePickerController在选择后不返回照片的元数据。但是,应用商店(Mobile Fotos,PixelPipe)中的几个应用程序似乎能够读取存储在其中的原始文件和EXIF数据,从而使应用程序可以从所选照片中提取地理数据。

It's well known that UIImagePickerController doesn't return the metadata of the photo after selection. However, a couple of apps in the app store (Mobile Fotos, PixelPipe) seem to be able to read the original files and the EXIF data stored within them, enabling the app to extract the geodata from the selected photo.

他们似乎是通过从 / private / var / mobile / Media / DCIM / 100APPLE / 文件夹中读取原始文件并通过EXIF库。

They seem to do this by reading the original file from the /private/var/mobile/Media/DCIM/100APPLE/ folder and running it through an EXIF library.

但是,我无法找到一种方法来匹配从UIImagePickerController返回的照片到磁盘上的文件。我已经探索了文件大小,但原始文件是JPEG,而返回的图像是一个原始的UIImage,使得它不可能知道所选择的图像的文件大小。

However, I can't work out a way of matching a photo returned from the UIImagePickerController to a file on disk. I've explored file sizes, but the original file is a JPEG, whilst the returned image is a raw UIImage, making it impossible to know the file size of the image that was selected.

我正在考虑制作一个哈希表,并匹配每个图像的前x个像素。

I'm considering making a table of hashes and matching against the first x pixels of each image. This seems a bit over the top though, and probably quite slow.

有任何建议吗?

推荐答案

执行此操作的淘气方法是遍历UIImagePickerViewController的视图,并在委托回调中选取所选图片。

The naughty way to do this is to traverse the UIImagePickerViewController's views and pick out the selected image in the delegate callback.

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

  id thumbnailView = [[[[[[[[[[picker.view subviews] 
                  objectAtIndex:0] subviews]
                  objectAtIndex:0] subviews]
                objectAtIndex:0] subviews]
                objectAtIndex:0] subviews]
              objectAtIndex:0];

  NSString *fullSizePath = [[[thumbnailView selectedPhoto] fileGroup] pathForFullSizeImage];
  NSString *thumbnailPath = [[[thumbnailView selectedPhoto] fileGroup] pathForThumbnailFile];

  NSLog(@"%@ and %@", fullSizePath, thumbnailPath);

}

这将给你全尺寸图像的路径,

That will give you the path to the full size image, which you can then open with an EXIF library of your choice.

但是,这会调用一个私有API,并且这些方法名称将被检测到苹果如果你提交这个程序。所以不要这样做,好吗?

But, this calls a Private API and these method names will be detected by Apple if you submit this app. So don't do this, OK?

这篇关于UIImagePickerController并从现有照片中提取EXIF数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆