Unable to insert image via DocumentBuilder.InsertImage using .NET

I’m trying to insert an image which I got as an byte array into a newly created document with the following code snippet:

Document additionalDoc = new Document();
DocumentBuilder builder = new DocumentBuilder(additionalDoc);
builder.InsertImage([Byte Array]);

This woks fine for most cases, but I encountered a PNG while testing which causes the following exception:

Could not create the bitmap with the specified parameters. Possible lack of system resources.: Parameter is not valid. FileFormat=Unknown
   at   ..ctor(Byte[] , SKRectI )
   at   ..ctor(Byte[] )
   at    . (Byte[] )
   at    . (Byte[] )
   at    . (Byte[] )
   at Aspose.Words.DocumentBuilder.InsertImage(Byte[] imageBytes, RelativeHorizontalPosition horzPos, Double left, RelativeVerticalPosition vertPos, Double top, Double width, Double height, WrapType wrapType)
   at Aspose.Words.DocumentBuilder.InsertImage(Byte[] imageBytes)

I don’t know what is so special with that picture (testImage.zip (11.6 KB))
This happens with the version of Aspose.Words v20.9.0.


We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-21107 . You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.


It is to inform you that the issue which you are facing is actually not a bug in Aspose.Words. So, we have closed this issue (WORDSNET-21107) as ‘Not a Bug’.

The image you want to insert into document is not a PNG file, it is a WebP image file. WebP is a relatively new (introduced in 2010 by Google) image format with good compression and image quality but is not yet supported by all web browsers and image viewers.

Aspose.Words does not recognize this format. You can convert WebP to PNG using Aspose.Imaging for .NET and insert the PNG into document using Aspose.Words.

The issues you have found earlier (filed as WORDSNET-21107) have been fixed in this Aspose.Words for Java 23.12 update.