Save Photo to Album with Metadata

PDF for offline use
Sample Code:
Related SDKs:

Let us know how you feel about this

Translation Quality


This recipe shows how to save a photo to the Photos Camera Roll Album, including image metadata.


The sample code uses the  Camera helper from TweetStation to take a picture, then demonstrates how to save it (with metadata) in the completion handler:

TweetStation.Camera.TakePicture (this, (obj) =>{
    var photo = obj.ValueForKey(new NSString("UIImagePickerControllerOriginalImage")) as UIImage;
    var meta = obj.ValueForKey(new NSString("UIImagePickerControllerMediaMetadata")) as NSDictionary;
    ALAssetsLibrary library = new ALAssetsLibrary();
    library.WriteImageToSavedPhotosAlbum (photo.CGImage, meta, (assetUrl, error) =>{
        Console.WriteLine ("assetUrl:"+assetUrl);

Additional Information

There is a simpler mechanism to save an existing UIImage to the Photo Album, but it does not include metadata:

var someImage = UIImage.FromFile("someImage.jpg");
someImage.SaveToPhotosAlbum((image, error) => {
    var o = image as UIImage;
    Console.WriteLine("error:" + error);

Xamarin Workbook

If it's not already installed, install the Xamarin Workbooks app first. The workbook file should download automatically, but if it doesn't, just click to start the workbook download manually.