dimonovdd / Xamarin.MediaGallery

This plugin is designed to picking and save images and video files from native gallery of Android and iOS devices and capture photos
MIT License
148 stars 18 forks source link

Picked image is rotated 90 degrees on Android #101

Closed dzebas closed 2 years ago

dzebas commented 2 years ago

Description When you pick image with PickAsync on Android result image is rotated by 90 degrees. Same code works fine in iOS.

Expected behavior Picked image should be displayed in same orientation as it was originally taken e.g. portrait or landscape.

Steps to reproduce the behavior

var request = new MediaPickRequest( 1, MediaFileType.Image )
{
    PresentationSourceBounds = PhotoSize.Full,
    Title = "Select image"
};

var results = await MediaGallery.PickAsync( request );
var file = results?.Files?.ToArray()?.First();

byte[] imageData;
var stream = await file.OpenReadAsync(); 

using (MemoryStream ms = new MemoryStream())
{
    stream.CopyTo( ms );
    imageData = ms.ToArray();
}

return imageData;

Configuration Device: Samsung S7, Samsung Galaxy Tab A7 OS Version: Android 11 Plugin Version: 2.1.1 Framework: Xamarin

dimonovdd commented 2 years ago

Hi. This is correct behavior. Images are processed without any changes, See metadata

https://github.com/dimonovdd/Xamarin.MediaGallery/issues/99

dzebas commented 2 years ago

Thank you dimonovdd for a quick reply!

So if I want to display it the way it was originally taken, what should I do? You mentioned metadata, do you have any samples on how to use it?

Cheers.

dimonovdd commented 2 years ago

See sample project. I use MetadataExtractor