System.Drawing.Image.Width throws exception if it is called after Aspose.Words.Drawing.ImageData.SetImage method

Hello Aspose Team

We use Aspose.Words 23.6.0 on our .NET Framework 4.8 Project.

Following Code throws ArgumentException on Step 5:

// Step 1) Create Word document 
Document document = new Document();

// Step 2) Load an image from File
Image image = Image.FromFile(Path.Combine(Directory.GetCurrentDirectory(), "LogoIncident.jpeg"));

// Step 3) Following line executes normally.
int imageWidth1 = image.Width;

// Step 4) Load image data into shape
Shape shape = new Shape(document, ShapeType.Image);
shape.ImageData.SetImage(image);

// Step 5) Following line throws ArgumentException, because it is called after "shape.ImageData.SetImage(image)"
int imageWidth2 = image.Width;

This seems to happen only in some kind of image data. We could not found what kind of images are triggering this problem.

Attached you will find an example solution with latest version of Aspose(23.10.0) to reproduce this issue.

Thank you for your help and kind regards
Baki
AsposeImageProblem.zip (537.2 KB)

@Baca
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-26123

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

The issues you have found earlier (filed as WORDSNET-26123) have been fixed in this Aspose.Words for .NET 24.2 update also available on NuGet.

1 Like