Forum Xamarin Xamarin.Forms

How to save the metadata of the image taken and saved (using jamesmontemagno/MediaPlugin)?

IcolinoIcolino Member ✭✭
edited April 2019 in Xamarin.Forms

This is how I take the picture.

             Location location = new Location();
                    location.Latitude = 52.0271723411551;
                    location.Longitude = 0.764563267810425;

                photoFile = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions

                    SaveToAlbum = true,
                    Location = location,
                    Directory = "Komunalac",
                    Name = "photoKomunalac.jpg",
                    SaveMetaData = true,

                var picInfo = ExifLib.ExifReader.ReadJpeg(photoFile.GetStream());

                imageSource = ImageSource.FromStream(() =>
                    return photoFile.GetStream();

And the picInfo does indeed hold the metadata with GPS location.

But then when I want to get the picture back from album using :

 photoPicked = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions
                    PhotoSize = PhotoSize.Medium,
                    SaveMetaData = true

                picInfo = null;

                if (photoPicked != null)

                    picInfo = ExifReader.ReadJpeg(photoPicked.GetStream());

                    imageSource = ImageSource.FromStream(() =>
                          return photoPicked.GetStream();

picInfo here doesn't contain the GPS metadata. Anyone knows what went wrong or a different way to save the image with metadata to the android/ios?


  • SurbhiAroraaSurbhiAroraa Member ✭✭✭

    @Icolino How are you accessing the actual size of the photo? If we are saving meta data, where it is getting stored. how can i access that? TIA

  • IcolinoIcolino Member ✭✭

    I am using ExifLib.PCL for getting the metadata back from the picture. ExifReader.ReadJpeg is where I get the metadata from.

    If I use a camera outside my app, metadata works fine.

    But if I use the mediaplugin and takephotoasync, no metadata shows up after I try to take that picture later out of the gallery. Picture is saved in the external storage if it exists, together with metadata.

Sign In or Register to comment.