Is there a way to improve image quality?


I am inserting bitmaps 32-bit color bitmaps. However, quality seems to be reduced due to compression. Is there a way to control image compression?


Hi, we have this issue on our task list, will address in the near future.


Any new status on this capability?


Let’s work out a suitable solution.

Do you insert the image using DocumentBuilder.InsertImage?

If you will be able to specify image format you want it saved in the Word file, will it be enough? What other options you think are possible?


Just some thoughts:

IMO, image compression / quality varies from application to application and should be outside the scope of DocumentBuilder. I think a compromise would be to keep the current InsertImage() method as is, and add another InsertImage(System.Image image, bool performCompression) to enable/disable conversion/compression of images.

If Word binary only allows certain types of images (jpeg, bmp, wmf), maybe add another image type enumeration to the method to allow conversion.


That’s correct, word only allows images to be stored in certain formats.

In this problem, the image quality is lost because Aspose.Word saves all bitmap images in jpeg format and this makes images that consist of lines and solid colors look blurred. These images should better be saved as bmp, png, gif, pic or whatever. Aspose.Word does not perform any other compression.

That’s why I think if we can tell what format to use when saving the image, we have control over image quality in this case.


Ok, in my particular case, bmp and png support should suffice.


Please get latest Aspose.Word 1.9.8 as we changed Aspose.Word to save bitmap images in PNG format inside DOC files. We think it should still achieve good compression for file size and should not reduce image quality. Check release notes


Using InsertImage causes some colors to change. Are you guys using GDI+? If so, can Aspose.Word be updated to NOT perform color correction? (Our whites #ffffff, are becoming #fefefe).

new Bitmap(System.IO.Stream stream, bool useIcm) <-- the second parameter should be set to false to disable color correction.


Thanks for pointing this out, I will address this in the next couple of days or so.



Sorry we don’t seem to have a lot color correction experience. In my test white color does not change.

Plese provide more details, send your code and your images.


public void TestWhite()


Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

Bitmap srcImg = new Bitmap(100, 100);

Graphics srcG = Graphics.FromImage(srcImg);



TestUtil.Save(doc, @“DocBuilder\TestWhite Out.doc”);

MdlInlineShape shape = doc.Model.GetNodeAt(typeof(MdlInlineShape), 0) as MdlInlineShape;

Image dstImg = Image.FromStream(new MemoryStream(shape.ShapeEscher.Bse.Blip.ImageBytes ));

Bitmap bmp = new Bitmap(dstImg);

Assert.AreEqual(0xffffffff, (uint)bmp.GetPixel(0, 0).ToArgb());



Taking your code I produced a word doc. From there you can tell the bitmap inserted has the colors changing. I sent an email containg the document and the image copied from the created doc.

I used this code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Bitmap srcImg = new Bitmap(100, 100);
Graphics srcG = Graphics.FromImage(srcImg);
doc.Save(@“TestWhite.doc”, Aspose.Word.SaveFormat.FormatDocument);


Ok, I’ve changed my code so it saves the document and loads it again before checking and the pixel is still white.

ICM is a bit of mystery in .NET. I’ve found only Image.FromFile, Image.FromStream and some Bitmap constructors take parameters related to ICM. Other bitmap constructors seem to have ICM off by default from what I can see.

The problem is that we don’t really use any of these methods in Aspose.Word in the simple scenario of inserting an image and saving the document.

DocumentBuilder.InsertImage accepts an Image object already and does not do anything to it. When the document is saved, Image.Save method to save in PGN format is called - that’s it.

If you inserted a metafile, then yes, we create a bitmap and redraw the metafile to the bitmap to save the image as metafile (no other way to save as metafile from existing metafile). In this case I create a Bitmap using one of the constructors that do not have useIcm parameter.

From what I can tell it’s your computer is configured to apply ICM and probably that’s why you see bitmaps color corrected on your monitor since they are certainly white and my unit test confirms this. Or I totally miss something.


The pixel may appear to be white, but it’s actually RGB(254,254,254). There are 2 clues which tell me this: 1). As I code remotely, terminal services tries to “optimize” screen refreshes so color differences come out more exaggerated. As I open the newly created Word doc, the white bitmap image is clearly different from the rest of the page. 2.) Copy the image out of the Word doc and view it under your favorite image editor, the bitmap color comes out to be 254,254,254.


Well. I think we are both right.

Just emailed you a screenshot of the document you sent to me saying the image is different from white page - it is not different on my monitor. I think this proves that it’s your computer does the color correction, not Aspose.Word.


As I tried to describe, the color difference may not be able to be seen with the naked eye – for example, I can’t tell the difference either on my monitor. I can only tell if I print the document or view the document via Remote Desktop (which tries to optimize color data to repaint the client's screen).

To verify, you must take the image (after it has been inserted into Word), and view using Photoshop, Illustrator, Infraview, or any other picture viewer/editor that can display a pixel's RGB makeup.


Thanks, I understand this. Just had trouble finding an image editor that can show RGB values for a pixel.

Now I can see that the document you’ve sent me has 254,254,254. But the document produced on my machine has 255, 255, 255. We did not really change anything in this area recently, but to be sure you can try latest Aspose.Word hotfix.

From what I’ve read about color correction - it works when outputting to a specific device just for the device’s color profile. Since Aspose.Word does not really do anything apart from saving a given image using Image.Save I can only think it’s your OS adjusts colors. Not sure at which point in time and for which device.


from Ammo Collector:

I ran some tests using GDI+. Basically I found that PNG colors will change dependent on the display capabilities of each computer. BMP is stable, but only if the display capabilities match or exceed the bitmap’s original color depth.

So I’ve modified our code to reduce the 32-bit BMPs to 8-bit using an Octree Quantizer I found on the web. Doing this retains the 255,255,255 color before and after InsertImage.

However, I guess the problem we experienced that kicked off the image quality problem is still happening. Basically, our graphs are inserted into the doc and when printed, the “white” areas are not completely “white”, causing degradation when photocopying or faxing the document. You can see that the picture within Word is white, but when printed shows off-white.

However, if you right click the picture and format it, changing the brightness from 50% to 60% and contrast from 50% to 35%, it prints white. I know this is a crude workaround, but I’m stuck on any new ideas…