SixLabors/ImageSharp

The width and height of my image are reversed

Zhao-Michael opened this issue ยท 4 comments

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.2

Other ImageSharp packages and versions

N/A

Environment (Operating system, version and so on)

Win10 22H2

.NET Framework version

.Net8.0

Description

The width and height of my image are reversed, the width should be 1080, and Height should be 1440.

image

Steps to Reproduce

Just load the attached image in 'IMG1.zip', And Check the Width and Height of the image:

using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Metadata.Profiles.Exif;
using SixLabors.ImageSharp.Processing;

var path = @"IMG1.jpg";
using var image = Image.Load(path);
Console.WriteLine(image.Width.ToString() + " x " + image.Height.ToString());

Images

IMG1.zip

The width and height will be accurate. The EXIF metadata will indicate that the image is rotated.

So ImageSharp will not help to reverse width and height?
Since I see most of image viewer software like PS, window10 photos can handle it well...

if you run the img.Mutate(x=>x.AutoOrient()) it'll fix up the pixel data to be orientated as expected.

Note this is a difference stemming from audience expectations between image viewing and programmatic image manipulation. Image viewers are processing the data for humans to understand and physically look at where as ImageSharp is for manipulating the individual pixel data. Rotating the pixel data in memory (rather that adding a tag to tell a viewer to do it for you, which is the case here) would increase memory usage and loading time in places where not everyone will want/need that behaviour.

For what it's worth, this has been discussed before. @JimBobSquarePants has an example of a quick program you can write to verify what they're saying, in #1613