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

Free Support Forum - aspose.com

Shape to PNG conversion issue with Colors using .NET | ShapeRenderer

I would like to extract images from a Word document as separate png files. I use the ShapeRenderer and it works fine except for the colors being a bit off. The colors are shifted towards being lighter than in the original Word document. I have tried to experiement with various ImageShapeOptions, but nothing seems to help. Using Aspose.Words 21.1.0


Could you please ZIP and attach your input Word document and problematic images here for testing? We will investigate the issue and provide you more information it.

Aspose_extract_image_test.zip (349.8 KB)
Hi, thanks for responding. I have attached a Word document containing an image and also the extracted image I get. As you can see the extracted image has much lighter color tone than in the image in the document. The problem is consistent for all images, this is just an example. Also I have attached a code snippet showing how it is done.


Please note that Aspose.Words mimics the behavior of MS Word. You are facing the expected behavior of Aspose.Words. Your input Word document contains the TIFF image. If you covert the image to TIFF and PNG file format using MS Word, you will get the same output as generated by Aspose.Words.

To save the image to disk, please right click on the image in MS Word and select option 'Save as Picture.

Hi Tahir. But that is the problem. When I save through Word by Save as Picture… and chooses png, I get the correct colors. When I do it through Aspose rendering, the colors get changed. I have attached an image where you can see the difference. The left is from Aspose, the right is from Save as in Word.Comparison.png (128 KB)
In code through Aspose, I also scale it down a bit, could that have anything to do with it?

The problem seems to be with the ShapeRenderer class. If I simply do shape.ImageData.Save(output); the colors are ok. But if I use the ShapeRenderer (which I have to do in order to scale the images) the colors get messed up.


We have saved the Shape node to PNG and TIFF file formats with 100% scale using latest version of Aspose.Words for .NET i.e. 21.1. We have not found the shared issue at our end. Please check the attached output images. output.zip (377.0 KB)

Could you please share the value of scale, maxWidth, maxHeight that you used in your code for further testing?

The values are:
scale = 0.58
maxWidth = 1100
maxHeight = 2500
extension = “.png”

However, I have tried with scale =1.0F, it makes no difference.
I wonder if we could have a look at the full sample code you are using, maybe the problem is somewhere else. Thanks


Could you please check the output documents and let us know if you are satisfied with the output?

Yes, these images are correct. Just wondered if you mind sharing the full code example you are using? Thanks


We used the following code example to generate the image at Windows 10.

Document doc = new Document(MyDir + "Aspose_extract_image_test.docx");
Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true);

var resolution = 300F;
ShapeRenderer r = new ShapeRenderer(shape); 
ImageSaveOptions imageOptions = new ImageSaveOptions(SaveFormat.Png)
    Scale = 1.0f,
    Resolution = resolution,
    UseHighQualityRendering = true
r.Save(MyDir + "21.1.png", imageOptions);

The only difference I can see is that we use the following code to obtain the shapes:

NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);
foreach (Shape shape in shapes)
// same code here
It should not make any difference?
Thanks for your help so far, we will make som further experiments to figure out what is happening


Yes, your understanding is correct. The rendering shape to image code is same.

Aspose_input_output.zip (429.8 KB)
Hi Tahir. I have enclosed a full working VS project with your code. This code does not produce the correct png image on my system. The colors are skeewed as you can see when comparing to the original image in the word file. I have attached the example Word file and my output png as wellAsposeImageExtractTest_Copy.zip (4.9 KB)
Using Aspose.Words 21.1, on Windows 10


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-21744. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Thank you very much for your help!

Is there any news on this issue? We have downloaded the latest version of Aspose.Words .NET and it seems to not be resolved yet. Is this correct?


Unfortunately, the issue WORDSNET-21744 had been postponed (no estimate is available at the moment). We will inform you via this forum thread once there is an update available on it.

We apologize for your inconvenience.