static AndroidJavaObject RotateBitmap(AndroidJavaObject bitmap, string photoPath) { try { var ei = new AGExifInterface(photoPath); var orientation = ei.Orientation; switch (orientation) { case AGExifInterface.Orientations.Rotate90: return(RotateBitmap(bitmap, 90f)); case AGExifInterface.Orientations.Rotate180: return(RotateBitmap(bitmap, 180f)); case AGExifInterface.Orientations.Rotate270: return(RotateBitmap(bitmap, 270f)); default: return(bitmap); } } catch (Exception e) { Debug.LogError("Failed rotating bitmap"); Debug.LogException(e); return(bitmap); } }
static void GetImageTags(string imagePath) { var exif = new AGExifInterface(imagePath); var tags = exif.ToString().Split(','); foreach (var exifTag in tags) { Debug.Log(exifTag); } }
public void OnSetImageExifTags() { //Note, that PickImageFromGallery creates a duplicate of the selected image in the application folder //This is why you need to store the path to it, so you can later get it or its attributes AGGallery.PickImageFromGallery( selectedImage => { _imageFilePath = selectedImage.OriginalPath; var exif = new AGExifInterface(_imageFilePath) { Artist = "Osiris" }; Debug.Log("Artist: " + exif.Artist); exif.SaveAttributes(); Resources.UnloadUnusedAssets(); }, errorMessage => AGUIMisc.ShowToast("Cancelled picking image from gallery: " + errorMessage)); }