[Bug][iOS] Stream length from captured photo is larger than stream length from photo from camera
Description
I get FileResult from MediaPicker.CapturePhotoAsync and then I use OpenReadAsync to get stream from file. This stream has ~10mb, but when i use camera on the same iPhone i'm getting photo with ~2.5mb.
Expected Behaviour
The file should have the same size like file from camera.
Actual Behaviour
The file has size ~4 times larger than file from camera.
Basic Information
- Version with issue: 1.6.1
- IDE: Rider 2020.2.3
- Platform Target Frameworks:
- iOS: 14.4
- Nuget Packages: Xamarin.Forms 4.6.0.800
- Affected Devices: iPhone 5s, iPhone 11 Pro Max
@JanMatuszny I am also facing the same issue.
This is because for some reason on iOS the Xamarin.Essentials MediaPicker processes images from the camera as PNG, which is highly inefficient for photographs and more meant for screenshots and website assets etc. https://github.com/xamarin/Essentials/blob/7218ab88f7fbe00ec3379bd54e6c0ce35ffc0c22/Xamarin.Essentials/FileSystem/FileSystem.ios.cs#L195
I've created PR #1747 to fix this behaviour. Hopefully it gets merged.
This is quite a nasty one. What's stopping the PR from getting merged and a fix released?
I am also facing the same issue. I can see there's some errors because of which merging is blocked. If this isn't done in time, would have to switch to using the MediaPlugin to capture photos from camera.
Have switched back to using MediaPlugin temporarily until this has been fixed.
I've kept the essentials stuff but made a custom implementation for the ios camera action. Would be great to get this fixed, though...
for completeness, this is a pretty good starting point to make your own variant of the iOS take photo action, while keeping xamarin essentials for the other platforms. https://github.com/xamarin/Essentials/issues/1514#issuecomment-874148026
The newer code in .net maui still appears to have the same fault (see https://github.com/dotnet/maui/blob/main/src/Essentials/src/FileSystem/FileSystem.ios.cs
Is there any way of using fixed code (injecting somehow custom implementation)? Or any reasonable workaround for this?
@tomaszras-intive did you read the comments above
Sorry, I just did quick scrolling. Found some workaround in link that you posted (#1514) , Thanks!