0

When using ALAssetsLibrary, I used to save image to photo library with proper exif using the code below:

        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) {
          ...
          ...
     }

It's not clear how to translate that code when using PHPhotoLibrary. Can anyone provide the right way to save attachments along with the jpeg image?

Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131

1 Answers1

0

Use ImageIO to add Metadata to your JPEG/PNG image as described in the following article: Save the exif metadata using the new PHPhotoLibrary

holtmann
  • 6,043
  • 32
  • 44