ImageSharp icon indicating copy to clipboard operation
ImageSharp copied to clipboard

I have encountered a bug with heigh and width of image

Open sodiqjonovich opened this issue 1 year ago • 4 comments

Prerequisites

  • [X] I have written a descriptive issue title
  • [X] I have verified that I am running the latest version of ImageSharp
  • [X] I have verified if the problem exist in both DEBUG and RELEASE mode
  • [X] 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<Rgba32>(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

sodiqjonovich avatar May 14 '24 15:05 sodiqjonovich

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.

tocsoft avatar May 14 '24 16:05 tocsoft

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

sodiqjonovich avatar May 14 '24 18:05 sodiqjonovich

Also: #2644

tiesont avatar May 14 '24 19:05 tiesont

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.

JimBobSquarePants avatar May 14 '24 23:05 JimBobSquarePants