如何在 iOS 中从照片中获取图像 EXIF 元数据(ISO、光圈值、曝光度等)?

发布于 2024-09-08 04:03:33 字数 337 浏览 1 评论 0原文

在早期版本的 iOS 中,我可以通过 PLCameraController 获取 EXIF 字典,

-(void)cameraController:(id)sender
   tookPicture:(UIImage*)picture
   withPreview:(UIImage*)preview
      jpegData:(NSData*)rawData
  imageProperties:(id)imageProperties

这在 iOS 4+ 中不再有效。

如何在 iOS 中获取 EXIF 元数据,例如 ISO 编号、F 编号等?

In earlier versions of iOS I was able get EXIF dictionary with PLCameraController via

-(void)cameraController:(id)sender
   tookPicture:(UIImage*)picture
   withPreview:(UIImage*)preview
      jpegData:(NSData*)rawData
  imageProperties:(id)imageProperties

This no longer works in iOS 4+.

How can I get EXIF metadata in iOS such as ISO number, F-number etc?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风向决定发型 2024-09-15 04:03:33

从 iOS 4.1 开始,您可以获取使用 UIImagePickerControllerMediaMetadata 键拍摄的照片的图像元数据。

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

    NSDictionary *metadataDictionary = 
         (NSDictionary *)[info valueForKey:UIImagePickerControllerMediaMetadata];
    // do something with the metadata
}

如果您记录 [info description] 的输出,您可以看到所有可用的元数据 -

UIImagePickerControllerMediaMetadata =     {
    DPIHeight = 72;
    DPIWidth = 72;
    Orientation = 6;
    "{Exif}" =         {
        ApertureValue = "2.970853654340484";
        ColorSpace = 1;
        DateTimeDigitized = "2011:01:21 06:20:36";
        DateTimeOriginal = "2011:01:21 06:20:36";
        ExposureMode = 0;
        ExposureProgram = 2;
        ExposureTime = "0.01666666666666667";
        FNumber = "2.8";
        Flash = 32;
        FocalLength = "3.85";
        ISOSpeedRatings =             (
            100
        );
        MeteringMode = 1;
        PixelXDimension = 2048;
        PixelYDimension = 1536;
        SceneType = 1;
        SensingMethod = 2;
        Sharpness = 1;
        ShutterSpeedValue = "5.906892602837797";
        SubjectArea =             (
            1023,
            767,
            614,
            614
        );
        WhiteBalance = 0;
    };
    "{TIFF}" =         {
        DateTime = "2011:01:21 06:20:36";
        Make = Apple;
        Model = "iPhone 3GS";
        Software = "4.2.1";
        XResolution = 72;
        YResolution = 72;
    };
};

As of iOS 4.1, you can get the image metadata for a photo that was taken using the UIImagePickerControllerMediaMetadata key.

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

    NSDictionary *metadataDictionary = 
         (NSDictionary *)[info valueForKey:UIImagePickerControllerMediaMetadata];
    // do something with the metadata
}

If you log the ouput of [info description] you can see all the metadata that is available --

UIImagePickerControllerMediaMetadata =     {
    DPIHeight = 72;
    DPIWidth = 72;
    Orientation = 6;
    "{Exif}" =         {
        ApertureValue = "2.970853654340484";
        ColorSpace = 1;
        DateTimeDigitized = "2011:01:21 06:20:36";
        DateTimeOriginal = "2011:01:21 06:20:36";
        ExposureMode = 0;
        ExposureProgram = 2;
        ExposureTime = "0.01666666666666667";
        FNumber = "2.8";
        Flash = 32;
        FocalLength = "3.85";
        ISOSpeedRatings =             (
            100
        );
        MeteringMode = 1;
        PixelXDimension = 2048;
        PixelYDimension = 1536;
        SceneType = 1;
        SensingMethod = 2;
        Sharpness = 1;
        ShutterSpeedValue = "5.906892602837797";
        SubjectArea =             (
            1023,
            767,
            614,
            614
        );
        WhiteBalance = 0;
    };
    "{TIFF}" =         {
        DateTime = "2011:01:21 06:20:36";
        Make = Apple;
        Model = "iPhone 3GS";
        Software = "4.2.1";
        XResolution = 72;
        YResolution = 72;
    };
};
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文