jamesmontemagno / MediaPlugin

Take & Pick Photos and Video Plugin for Xamarin and Windows
MIT License
712 stars 360 forks source link

Image captured from Samsung device returns stream of incorrect length #825

Open tsequeira-vhs opened 4 years ago

tsequeira-vhs commented 4 years ago

If you are creating an issue for a BUG please fill out this information. If you are asking a question or requesting a feature you can delete the sections below.

Failure to fill out this information will result in this issue being closed. If you post a full stack trace in a bug it will be closed, please post it to http://gist.github.com and then post the link here.

Bug Information

var selectedPhoto = await CrossMedia.Current.PickPhotoAsync(); long size = selectedPhoto.GetStream().Length; This returns 3119122 instead of 1785830 for the below image.

The image is taken from a Samsung phone. For images taken from other devices like OnePlus, Pixel, etc are returning the correct file size. Only Samsung images have this issue.

I also created a Console application to read the same image file and it returned the correct value.

Also using Xamarians.Media (https://github.com/Xamarians/Media) returns the correct file length for the same image.

We are using the file length to take a decision whether to compress the image or not. We have a requirement to keep the image file size below 2MB.

Sample image to verify the issue. 20200316_110457

Version Number of Plugin: 4.0.1.5 Device Tested On: Samsung S6 Edge and Samsung A50 Simulator Tested On: NA Version of VS: 2019 16.5.0 Version of Xamarin: Xamarin.Forms 4.4.0.991640 Versions of other things you are using:

Steps to reproduce the Behavior

Expected Behavior

The stream should be of the correct length i.e. as per the file size

Actual Behavior

Incorrect stream length

Code snippet

var selectedPhoto = await CrossMedia.Current.PickPhotoAsync(); long size = selectedPhoto.GetStream().Length;

Screenshotst

lazmeister commented 4 years ago

We are having issues with a Samsung A10e that could be similar. but do not have access to the device myself to debug.

tsequeira-vhs commented 4 years ago

@jamesmontemagno Is it a known issue?