1

I have app that has an in-app camera that the user can take picture using it.

I want that when the user take a picture, the picture will be saved to the device's camera roll.

I've tried to do it with:

UIImageWriteToSavedPhotosAlbum(imageToSave, nil, nil, nil)

but then I realised it's not saving it with the metadata of the image (GPS and capture time).

My question is: how can I save the image with its metadata to the camera roll (Swift 3)?

Thank you very much!

rmaddy
  • 314,917
  • 42
  • 532
  • 579
FS.O6
  • 1,394
  • 2
  • 20
  • 42
  • Hello this question might help you :) http://stackoverflow.com/questions/38132357/swift-custom-camera-save-modified-metadata-with-image – 0ndre_ Sep 28 '16 at 17:13
  • @0ndre_ That's really complicated, and I can't understand what relates to my question and what doesn't. Is there any simpler and clearer way to do it? Just save a photo with GPS and time. Or can you please summarise me what should I do? Thanks – FS.O6 Sep 28 '16 at 17:17
  • My answer here (http://stackoverflow.com/a/43375633/6431067) shows a Swift solution for how to save an image to the Camera Roll using the Photos API while preserving any changes made to the metadata (specifically adding GPS/capture time to the image). – Undrea Apr 12 '17 at 18:23

1 Answers1

0

If you need to save some exif, you can use SimpleExif pod

First create a ExifContainer:

ExifContainer *container = [[ExifContainer alloc] init];

and populate it with all requred data:

[container addUserComment:@"My data"];
[container addCreationDate:[NSDate dateWithTimeIntervalSinceNow:-10000000]];
[container addLocation:locations[0]];

Then you can add this data to image:

NSData *imageData = [imageToSave addExif:container];

And Save

UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:imageData], nil, nil, nil);