Select to view content in your preferred language

Change orientation of PictureMarkerSymbol, Maui

503
5
08-15-2024 08:42 AM
KarenRobine1
Regular Contributor

I'm creating PictureMarkerSymbols from photos that my user selected. I'm creating them using a Uri pointing to the data file. The problem I'm running into is that the photo is coming in rotated incorrectly.   I'm able to get the width and height of the photo using the following (this needs to run on iOS and Android):

using IImage = Microsoft.Maui.Graphics.IImage;

IImage? image = null;

using (Stream stream = File.OpenRead(<path to image>))
{
image = PlatformImage.FromStream(stream);

//Now I have image width and height so I can see if the image is landscape or portrait; and change aspect accordingly

}

The code above works on any platform. But I'm not sure how to get the proper orientation as a PictureMarkerSymbol. Ideas?

Note: I can stick it in an ImageSource which works perfectly.

0 Kudos
5 Replies
PreetiMaske
Esri Regular Contributor

Have you tried setting Angle property on PictureMarkerSymbol?

0 Kudos
KarenRobine1
Regular Contributor

I haven't yet, but I would think that would fix the issue. The only problem is that I don't know the angle to set the image to since I allow the user to select one of their own photos from a device and I show it as a PictureMarkerSymbol.

This led me to some articles like the following:

https://stackoverflow.com/questions/27835064/get-image-orientation-and-rotate-as-per-orientation

https://www.ryadel.com/en/change-image-orientation-iphone-andor-android-phone-pics-net-c/

But I'm hoping I don't have to go down this road. The idea in the first article only works on windows as it requires adding System.Drawing.Common Nuget package and parts (maybe all, not sure) only works on windows.  The second article gets really deep and ends up modifying the actual image (which would break my Single Photo View (see comment below). Due to this, I have to move the photo (I've already trashed photos in testing this). Was kind of hoping for a more OOB solution from ESRI??

Alternatively, I'm building a single photo ContentView. I can use that, but I think I need that to show up as a Graphics Popup or something?

Thoughts?

0 Kudos
PreetiMaske
Esri Regular Contributor

Based on the description of your use case, it seems like you are looking for a photo editor that can change the orientation of a picture to be used as a PictureMarkerSymbol. Unfortunately, ESRI does not provide an out-of-the-box solution for this specific task. The purpose of the symbol is to draw a feature or graphic using the image provided, and there is no information in the image itself that indicates the correct orientation. You may need to use a separate photo editing tool to adjust the orientation of the picture before using it as a symbol.

 

0 Kudos
KarenRobine1
Regular Contributor

All of the photos show up correctly when using DataBinding to attach to an image though, so there must be some header information in there that orients the photos correctly.  I've linked to some resources in my previous message. I'm guessing that the ESRI code doesn't look at photos headers when setting up a PictureMarkerSymbol?

0 Kudos
dotMorten_esri
Esri Notable Contributor

I think I see what you're getting at but not 100% sure. Could you provide a small application that demonstrates the problem that we can use to investigate?

0 Kudos