Image.Width and Image.Height properties are swapped

Running this code on the attached image using Aspose.Imaging for .NET 20.5 : input.jpg (2.4 MB)

var img = Aspose.Imaging.Image.Load("input.jpg");
Console.WriteLine("Width: " + img.
Console.WriteLine("Height: " + img.Height);

gives the following output:

Width: 3648
Height: 2736

However, when viewing the image in a graphics viewer (such as Irfanview) or browser, its dimensions are swapped: Width = 2736, Height = 3648.

Can you please advise how to get the correct dimensions. If the image is auto-rotating, is there a flag to show the orientation?

Thanks

@ast3,

I have tested using Aspose.Imaging for .NET 20.5 and there is no issue my end while accessing the image width and height. Please observe the attached snapshot image for properties and console output.

image.png (26.7 KB)

Hi Mudassir,

Please see my screenshot showing the Width and Height properties are swapped. I get the same result on another computer.

ss1.png (9.9 KB)

We are running the same code but getting different result, so there must be some other factor. Do you have any ideas why the Width & Height properties are returning different values on my computers than on yours?

Thanks

@ast3.

Can you please possibly provide the working sample Visual Studio project you are using along with information about Windows version and Screen resolution settings you have. I may use this information to contact our team for possible reason.

Hi Mudassir

Please find attached the Visual Studio console app I am using: AsposeImagingTest.zip (2.9 MB) (excluding the Aspose.Imaging v20.5 Nuget package)

When I run it, it produces the following:

C:\AsposeImagingTest\bin\Debug>AsposeImagingTest.exe
Width: 3648
Height: 2736

The environment is:

  • Microsoft Windows 10 Home Version 10.0.18363 Build 18363
  • x64-based PC
  • Intel Core i5-5200U CPU @ 2.20GHz, 2195 Mhz
  • IntelĀ® HD Graphics 5500
  • 1920 x 1080 x 60 hertz
  • Bits/Pixel 32
  • .Net Framework 4.8

Thanks

@ast3,

I have worked with new image and it has reproduced the issue on my end. A ticket with ID IMAGINGNET-3957 has been created to investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

@ast3

Can you please try using latest Aspose.Imaging for .NET 21.2. Actually, the second image (input_new.jpg) is stored as image with dimensions 3648x2736, but it also has EXIF tag ExifOrientation.LeftBottom, which says that we must rotate image by 90 degrees.
By default we load the image as is, without any changes. If you wish to apply EXIT information to image, you should use following code:

using (var img = Aspose.Imaging.Image.Load("input.jpg"))
{
    // if image has EXIF orientation info than apply it
    if (img is JpegImage jpegImage)
        jpegImage.AutoRotate();
    Console.WriteLine("Width: " + img.Width);
    Console.WriteLine("Height: " + img.Height);
}

using (var img = (JpegImage)Aspose.Imaging.Image.Load("input_new.jpg"))
{
    // if image has EXIF orientation info than apply it
    if (img is JpegImage jpegImage)
        jpegImage.AutoRotate();
    Console.WriteLine("Width: " + img.Width);
    Console.WriteLine("Height: " + img.Height);
}

Hi Mudassir,

I have tested and this works to correct the reported dimensions.

Thanks!

@ast3

Thank you for your feedback. Can we close the issue now on our end?