We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Pictures created using the Shape.ToImage method can be the wrong size

I have attached a document with one picture, that has been rotated by 90 degrees. I included a screenshot from Excel, that clearly shows that the width and the height of the image are both the same value. However, when you generate an image from the Shape.ToImage method, the resulting image has different dimensions. I have included the image to show this. If you prefer, you can generate your own image using the following code, obviously after changing the file paths:

Workbook workbook = new Workbook(@"C:\Users\sheridan.yuen\Downloads\IncorrectSizeOfRotatedImage.xlsx");
Shape shape = workbook.Worksheets[0].Shapes[0];
Aspose.Cells.Drawing.Picture picture = (Aspose.Cells.Drawing.Picture)shape;
picture.ToImage(@"C:\Users\sheridan.yuen\Downloads\IncorrectSizeOfRotatedImage.png", new ImageOrPrintOptions() { ImageType = ImageType.Png });

Please note that your Picture object shows the correct dimension values, so it’s just the output image size that is incorrect.

IncorrectSizeOfRotatedImage.zip (23.4 KB)

I have just discovered that this bug has nothing to do with rotation. It also exists for unrotated objects. I added a triangle shape to the previously provided spreadsheet, and it suffers from the same problem, but the size of its output image is incorrect by a larger degree than the previous example. I have also attached an image that highlights the discrepancy in the sizes of the Shape object and the output image.

IncorrectSizeOfRotatedImage.zip (44.5 KB)

@workshare,

We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46615 - Shape.ToImage() exports images of different size

Thank you ahsaniqbalsidiqui.

@workshare,
You are welcome.

@workshare,

Please try our latest version/fix: Aspose.Cells for .NET v19.3.1:

Aspose.Cells19.3.1 For .NetStandard20.Zip (4.0 MB)
Aspose.Cells19.3.1 For .Net2_AuthenticodeSigned.Zip (4.8 MB)
Aspose.Cells19.3.1 For .Net4.0.Zip (4.8 MB)

We fixed the issue(s) for the sample in IncorrectSizeOfRotatedImage.zip. For the triangle shape sample in the zipped archive IncorrectSizeOfRectangle.zip, the output image will be inflated as it contains border. However the size of shape is original size, it is not border’s width. So, this is not a bug and we won’t fix it.

The issues you have found earlier (filed as CELLSNET-46615) have been fixed in Aspose.Cells for .NET v19.4. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi