.NET MAUI - Camera View - Images Portrait

NickNN 40 Reputation points
2025-04-25T14:19:39.2266667+00:00

Hello,

I'm using CameraView from CommunityToolkit.Maui.Camera, and I take photos that I display in another view.

When I take the image with the iPad in portrait mode, the photo I took displays fine. I even save it to disk and display it later in another view, and it still looks fine, vertically.

But then, when I generate the b64 of that image, it rotates. It only happens when the image is taken vertically. How can I fix this?

I've tried rotating it with SixLabors.ImageSharp, but it takes a long time.

Any ideas for an alternative? Thanks.

Developer technologies | .NET | .NET MAUI
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Harry Vo (WICLOUD CORPORATION) 1,315 Reputation points Microsoft External Staff
    2025-08-26T04:31:23.67+00:00

    Hi @NickNN , thank you for reaching out on Microsoft Q&A!

    When I take the image with the iPad in portrait mode, the photo I took displays fine. I even save it to disk and display it later in another view, and it still looks fine, vertically.

    Actually, photo pixels are saved sideways (landscape) and EXIF metadata will help you save the orientation setting (portrait or landscape). However, when you convert to Base64, the EXIF tag gets ignored, which leads to the rotation to default (landscape).

    I've tried rotating it with SixLabors.ImageSharp, but it takes a long time.

    You can try normalizing the image before encoding. When you load the photo into a UIImage, iOS automatically reads the EXIF orientation. Then, redraw the UIImage into a new graphics context, which will strip away the EXIF flag and create a new image where pixels are already rotated. Finally, you can do your work with the freshly created image.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.