Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

返回的图片exif信息缺失 #719

Closed
Fairy-happy opened this issue Dec 29, 2017 · 11 comments
Closed

返回的图片exif信息缺失 #719

Fairy-happy opened this issue Dec 29, 2017 · 11 comments

Comments

@Fairy-happy
Copy link

返回的图片无法获取全部的exif信息

@banchichen
Copy link
Owner

@Fairy-happy 你用asset也获取不到吗?通过asset是可以获取图片的所有信息的。

@banchichen
Copy link
Owner

#263

@Fairy-happy
Copy link
Author

看了你发的链接,能取到位置等信息,但取不到相机信息

@banchichen
Copy link
Owner

@Fairy-happy 你用系统的UIImagePickerController,能取到吗?

@Fairy-happy
Copy link
Author

用系统的可以从info里面根据URL获取数据,asset里面没细看

@banchichen
Copy link
Owner

@Fairy-happy UIImagePickerController返回的info,我看是这样子的:

{
    UIImagePickerControllerImageURL = "file:///Users/tanzhen/Library/Developer/CoreSimulator/Devices/B7DC08D2-A6FB-4EF9-9C6E-1011139712D7/data/Containers/Data/Application/8DDBC040-A0FB-4B82-8240-2EFEC95B2D4F/tmp/F1649213-174B-47E1-8B71-DAE947504645.jpeg";
    UIImagePickerControllerMediaType = "public.image";
    UIImagePickerControllerOriginalImage = "<UIImage: 0x6080000ae580> size {4288, 2848} orientation 0 scale 1.000000";
    UIImagePickerControllerPHAsset = "<PHAsset: 0x7ffe46931460> 106E99A1-4F6A-45A2-B320-B0AD4A8E8473/L0/001 mediaType=1/0, sourceType=1, (4288x2848), creationDate=2011-03-13 00:17:25 +0000, location=1, hidden=0, favorite=0 ";
    UIImagePickerControllerReferenceURL = "assets-library://asset/asset.JPG?id=106E99A1-4F6A-45A2-B320-B0AD4A8E8473&ext=JPG";
}

你是根据UIImagePickerControllerImageURL来获取exif数据吗?

@Fairy-happy
Copy link
Author

   CGImageSourceRef imageSource = CGImageSourceCreateWithURL((CFURLRef)fileUrl, NULL);
   CFDictionaryRef imageInfo = CGImageSourceCopyPropertiesAtIndex(imageSource, 0,NULL);
   NSDictionary *exifDic = (__bridge NSDictionary *)CFDictionaryGetValue(imageInfo, kCGImagePropertyTIFFDictionary) ;

@banchichen
Copy link
Owner

@Fairy-happy 好的,用这个代理方法,这个方法会返回info信息:

- (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray<UIImage *> *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto infos:(NSArray<NSDictionary *> *)infos 

其中的info是这样的:

{
    PHImageFileOrientationKey = 0;
    PHImageFileSandboxExtensionTokenKey = "337768e585ea8914faa48e4255d71f8956fc81e4;00000000;00000000;000000000000001a;com.apple.app-sandbox.read;01;01000005;00000002006926bb;/users/tanzhen/library/developer/coresimulator/devices/b7dc08d2-a6fb-4ef9-9c6e-1011139712d7/data/media/dcim/100apple/img_0008.jpg";
    PHImageFileURLKey = "file:///Users/tanzhen/Library/Developer/CoreSimulator/Devices/B7DC08D2-A6FB-4EF9-9C6E-1011139712D7/data/Media/DCIM/100APPLE/IMG_0008.JPG";
    PHImageFileUTIKey = "public.jpeg";
    PHImageResultDeliveredImageFormatKey = 9999;
    PHImageResultIsDegradedKey = 0;
    PHImageResultIsInCloudKey = 0;
    PHImageResultIsPlaceholderKey = 0;
    PHImageResultRequestIDKey = 10;
    PHImageResultWantedImageFormatKey = 4035;
}

PHImageFileURLKey就是UIImagePickerControllerImageURL

@Fairy-happy
Copy link
Author

已经找到这个方法了,经测试好用,谢谢

@luhuafei
Copy link

@Fairy-happy 能告知怎么获得的嘛? 我这边之或得exif和jiff 等, 不能拿到iptc相关信息

@Fairy-happy
Copy link
Author

@Fairy-happy 能告知怎么获得的嘛? 我这边之或得exif和jiff 等, 不能拿到iptc相关信息

你具体想获得什么信息,或者你可以通过UIImagePickerControllerImageURL查找到更多信息吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants