Wrong Image Width and Height from smartphone camera pics

Hello all,

I’m building a game for UWP and Windows Standalone in wich the user can upload an image to interact with and I just found a weird behaviour with the pics that comes straight from smartphones (at least samsung that is the one I own) when I read the Width(W) and Height(H)

I’m using:

Windows.Storage.FileProperties.ImageProperties imageProperties = await file.Properties.GetImagePropertiesAsync();

                                    picWidth = Convert.ToInt32(imageProperties.Width);
                                    picHeight = Convert.ToInt32(imageProperties.Height);

to get the W and H in UWP

and for Standalone:

using (var image = System.Drawing.Image.FromStream(fileStream, false, false))
                {
                    picHeight = image.Height;
                    picWidth = image.Width;
                }

both of them give the same result but in the images that comes from my Note9 the W and H comes inverted.

In the Pic’s Windows Properties the W and H are correct.

My Questions:
1.- Is there a metoth to Get the W and H as the Windows Properties shows
2.- Is there a way to detect or handle pics from smartphones,

With the UWP metoth I can get much more information about the Pic like orientation and with this info I can invert in the code but in the Standalone code I can’t find something like this.

Using:
UNITY 2020.3.3F1
Windows 10

Notes:

  • In other windows apps (Photoshop, Photos, Paint) the Pics are shown in correct way
  • With the UWP metoth I can get much more information about the Pic, like its orientation, and with this info I can invert the W&H in the code, but for the Standalone code I can’t find something like this.
  • If I export or save the same Pics from the mentioned apps the issue is gone.

Last time I checked it screen.width and screen.height were correct on one of my android apps.
Use the unity version

and

My mistake to get the dimensions of an image file there is no other way to get it aside decoding the image file. It’s the first few lines of the image once decoded. It’s required to format the reconstruction of the colour data

Hello @AnimalMan , thanks for your answer

Yes, This is related to the Screen size

I ended up by give the user an option to flip the texture, something like this, maybe is what you mean? because after try different approachs I think that maybe I can have the same problem with pics coming from different devices and manufacturers so this could be not a workaround but the solution to my problem.

I’ll let the Question open because I’m still interested on how to the see the properties as the “Properties Windows”