【问题标题】:Save Image metadata PHPhotoLibrary vs ALAssetsLibrary保存图像元数据 PHPhotoLibrary 与 ALAssetsLibrary
【发布时间】:2017-05-12 09:07:16
【问题描述】:

在使用 ALAssetsLibrary 时,我曾经使用以下代码将图像保存到带有适当 exif 的照片库:

        NSInteger orientation = 2;// Or whatever
        NSData *jpegData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];

CMSetAttachment(imageDataSampleBuffer, kCGImagePropertyOrientation,
                [NSNumber numberWithInt: orientation],
                kCMAttachmentMode_ShouldPropagate);

    ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];

    CFDictionaryRef attachments = CMCopyDictionaryOfAttachments(kCFAllocatorDefault, imageDataSampleBuffer, kCMAttachmentMode_ShouldPropagate);

    [library writeImageDataToSavedPhotosAlbum:jpegData metadata:(id)attachments completionBlock:^(NSURL *assetURL, NSError *error) {
          ...
          ...
     }

不清楚在使用 PHPhotoLibrary 时如何翻译该代码。谁能提供正确的方法来保存附件以及 jpeg 图像?

【问题讨论】:

    标签: ios10 alassetslibrary cgimage phasset phphotolibrary


    【解决方案1】:

    使用 ImageIO 将元数据添加到您的 JPEG/PNG 图像中,如下文所述: Save the exif metadata using the new PHPhotoLibrary

    【讨论】:

      猜你喜欢
      • 2016-02-03
      • 1970-01-01
      • 2016-11-12
      • 1970-01-01
      • 2015-04-05
      • 2023-01-23
      • 1970-01-01
      • 2012-07-08
      • 1970-01-01
      相关资源
      最近更新 更多