Skip to content
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

I have encountered a bug with heigh and width of image #2736

Open
4 tasks done
sodiqjonovich opened this issue May 14, 2024 · 4 comments
Open
4 tasks done

I have encountered a bug with heigh and width of image #2736

sodiqjonovich opened this issue May 14, 2024 · 4 comments

Comments

@sodiqjonovich
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

ImageSharp version

3.1.4

Other ImageSharp packages and versions

3.1.4

Environment (Operating system, version and so on)

Windows 11, Linux Ubuntu

.NET Framework version

.net6

Description

image

This is my picture, in here width = 4282pixels, height = 5712 pixels.
But In ImageSharp showing wrong

image

Steps to Reproduce

using (var imageSharp = SixLabors.ImageSharp.Image.Load(image.OpenReadStream()))
{
var width = imageSharp.Width;
var height = imageSharp.Height;

// Check image ratio
double allowedRatio = 0.01;
var ratio = (double) width / height;
if (Math.Abs(ratio - ((double)_ratioX / _ratioY)) >= allowedRatio)
{
    return new ValidationResult($"Image ratio should be {_ratioX}:{_ratioY}");
}

}

Images

image
image

@tocsoft
Copy link
Member

tocsoft commented May 14, 2024

this is most likely due to some metadata tag setting a rotation (EXIF). We don't handle that automagically like windows/viewer software does.

You will want to call the img.Mutate(p=>p.AutoOrient()) helper to force the pixel into the correct orientation.

@sodiqjonovich
Copy link
Author

sodiqjonovich commented May 14, 2024

I should only get width and height of image, how can i get via this library

@tiesont
Copy link
Sponsor

tiesont commented May 14, 2024

Also: #2644

@JimBobSquarePants
Copy link
Member

I should only get width and height of image, how can i get via this library

The height and width of the image are the ones reported by the library. This is exactly the same as other libraries. If you want orientation dimensions you will have to check the image metadata.

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

No branches or pull requests

4 participants