-
Notifications
You must be signed in to change notification settings - Fork 471
[Bug] [CameraView] [Android] Taken photos are rotated incorrectly #1695
Comments
A better workaround is to write EXIF data into the image using AndroidX ExifInterface: public void SetExifOrientation(string filePath, double rotation)
{
int orientationValue = rotation switch
{
90d => ExifInterface.OrientationRotate90,
180d => ExifInterface.OrientationRotate180,
270d => ExifInterface.OrientationRotate270,
_ => ExifInterface.OrientationNormal,
};
var exif = new ExifInterface(filePath);
exif.SetAttribute(
tag: ExifInterface.TagOrientation,
value: orientationValue.ToString());
exif.SaveAttributes();
} |
Hi @lassana, could you please confirm if it is still happening in the latest XCT version? |
This comment was marked as off-topic.
This comment was marked as off-topic.
Hi @lassana thanks for testing! If possible, could you please test it using XCT sample app as well? |
@lassana I think I understand what you mean. You are talking about how the CameraView currently works. And yes, you have to handle the rotation by yourself based on the Rotation argument. So it's not a bug. It's more a behaviour change request, right? @jfversluis what do you think? |
Yep that's what my workaround does, but the question is why would you have to to deal with additional properties at all? Isn't it the library's job to generate a properly rotated image so developers wouldn't have to copy-paste the same workaround? I guess rotating the whole image might be quite time-consuming, but writing the EXIF data works rather quickly. BTW it seems it's been planned at some point but left as a to-do: Lines 380 to 388 in 02884f5
It certainly can be treated as the following behavior change: make the CameraView behave on Android just like it does on iOS, because the described issue does not happen on iOS. However, the image has to be stored as a file in order to use AndroidX ExifInterface, so |
So do I. So do I when I use 1.2.0. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Hey everyone! Thank you for your patience here! Would you maybe be able to test version 2.1.0-build-64069.1871 from this NuGet feed: https://pkgs.dev.azure.com/xamarin/public/_packaging/XamarinCommunityToolkit-PullRequests/nuget/v3/index.json That is the result of a PR I just made to fix this rotation thing. Let me know if this works! |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
|
@jfversluis also does this fix videos too? |
@lassana |
V2.0.5 (the latest available right now) still has this rotation problem on Android (works fine on iOS!) Problem: not only photos are rotated wrong - but videos too! If i rotate my Pixel4a 90° to the right (to get a landscape video) the video is head down or so.. very weird behaviour |
I cannot find any newer version than 2.0.5 with this link ... where can i find the Android fix to apply it myself? |
@jfversluis I tested version 2.1.0-build-64069.1871 and it is working. |
@DaviBittencourt nice! Would have been nice to have this fix about 2 years ago though. |
Any idea when the version with the solution will be release for production or available in nuget.org? As of now I can update upto 2.0.5 version of xamarin.community.toolkit. |
Description
When taking a photo with CameraView on Android, photos are rotated incorrectly.
Previously reported in #297, #751, #779. PRs #307, #886 claim to fix this but they don't.
Stack Trace
Link to Reproduction Sample
CameraBug.zip
Steps to Reproduce
Confirmed on Pixel 3a XL Android 12 and Xiaomi Redmi 3s Android 6.0.
Open the attached project and run.
Press the Capture button which invokes the
Shutter()
method:ImageView
(right below the camera view):Expected Behavior
ImageData
ofMediaCapturedEventArgs
contains a JPEG image with correct orientation applied.Actual Behavior
ImageData
is an incorrectly rotated JPEG and additional manual transformations are required.Basic Information
Workaround
A workaround is to use
ImageSharp
where you can manually rotate the image according toMediaCapturedEventArgs.Rotation
property. It works pathetically slow though.Reproduction imagery
The text was updated successfully, but these errors were encountered: