Skip to content

LoadImageInfo does not return correct values for width and height if image is from mobile phone and image is in portrait mode #470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
peter-tornqvist-kan opened this issue Jan 29, 2025 · 4 comments

Comments

@peter-tornqvist-kan
Copy link

As per the title, if I want to get width/height of an image in portrait mode from a mobile phone, the width and height are incorrect (width is wider that height).

I use this code to call the method:

using (var stream = imageBlob.OpenRead())
			{
				string[] info = new[] { "source.width", "source.height", "final.width", "final.height", "result.ext", "result.mime" };

				var length = stream.Length; // set length before calling LoadImageInfo
				var result = CurrentImageBuilder.LoadImageInfo(stream, info);
				return new Tuple<int, int, long>((int)result["source.width"], (int)result["source.height"], length);
			}

Is there some setting I am missing in the call to LoadImageInfo (i.e in info)?

I've found code here on github that seems to indicate that you do actually autorotate by default for some calls (in ImageBuilder.PostDecodeStream), but I am unsure if this code is > 4.2.8 or not called when calling LoadImageInfo.

We are currently on ImageBuilder 4.2.8

Thanks

@lilith
Copy link
Member

lilith commented Feb 12, 2025

Have you checked final.width, final.height? the source values would be pre-rotation.

@peter-tornqvist-kan
Copy link
Author

I haven't. I always presumed that those were for when you did any crop/resize actions and they would hold the resulting size of the cropped/resized image. Is this documented somewhere, I was unable to find it?

@lilith
Copy link
Member

lilith commented Feb 13, 2025 via email

@peter-tornqvist-kan
Copy link
Author

Yes, I know how phone images store data, that's why I never considered that final.* would hold the rotated/cropped dimensions even if I hadn't done any cropping/rotating. To me, that just doesn't make sense, but now I know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants