Experiencing very poor quality in wmf => png transformation

Dear,

I am experiencing very low quality when transforming wmf images (found in a MS Word docx).
The quality has been very low for a long time but I had hopes for more recent aspose would fix this.
Please see both MS Word and PNG side-by-side
Screenshot 2025-05-13-105104.jpg (100.5 KB)
Do you have suggestions on improving this?
Using v25.5 on java 16 (the jar)
Thanks
Geert Bormans
PS: my client has a license + support. Maybe I should send this in through a different support channel, but I thought advice in this could help others
(but a fast fix would be appreciated)

@GeertBormans

To improve the quality of WMF to PNG transformations using Aspose.Imaging, you can utilize the WmfRasterizationOptions class to customize the rasterization settings. Here’s a step-by-step guide to help you achieve better results:

  1. Load the WMF Image: Start by loading the WMF image that you want to convert.

  2. Set Rasterization Options: Create an instance of WmfRasterizationOptions and specify the desired page width and height. This is crucial as it determines the resolution of the output PNG image. You can also set the background color if needed.

  3. Save as PNG: Use the PngOptions class to save the image, passing the rasterization options to ensure that the conversion uses the specified settings.

Here’s a sample code snippet in Java that demonstrates this process:

import com.aspose.imaging.Color;
import com.aspose.imaging.Image;
import com.aspose.imaging.ImageOptionsBase;
import com.aspose.imaging.imageoptions.PngOptions;
import com.aspose.imaging.imageoptions.WmfRasterizationOptions;

public class ConvertWMFToPNG {
    public static void main(String[] args) {
        // Load the WMF image
        String inputFileName = "path/to/your/image.wmf";
        String outputFileName = "path/to/your/output/image.png";

        try (Image image = Image.load(inputFileName)) {
            // Set rasterization options
            WmfRasterizationOptions rasterizationOptions = new WmfRasterizationOptions();
            rasterizationOptions.setPageWidth(image.getWidth() * 2); // Increase width for better quality
            rasterizationOptions.setPageHeight(image.getHeight() * 2); // Increase height for better quality
            rasterizationOptions.setBackgroundColor(Color.getWhiteSmoke());

            // Create PNG options and set rasterization options
            ImageOptionsBase pngOptions = new PngOptions();
            pngOptions.setVectorRasterizationOptions(rasterizationOptions);

            // Save the image as PNG
            image.save(outputFileName, pngOptions);
        }
    }
}

Key Points:

  • Increase Page Dimensions: By doubling the width and height in the rasterization options, you can enhance the output quality.
  • Background Color: Setting a background color can help in cases where the WMF image has transparent areas.

If you continue to experience issues with image quality, consider checking for updates to the Aspose.Imaging library, as newer versions may include improvements and bug fixes related to image processing.

For further details, you can refer to the official documentation on converting WMF images to PNG using Aspose.Imaging here.

If you have a support license, you might also want to reach out through the official support channels for more tailored assistance.

Sources:
[1]: Convert WMF Metafiles to Scalable Vector Graphics | Aspose.Imaging Java …

please find a zip with a set of test wmf files
media.zip (4.3 MB)

Hello @GeertBormans ,
Your original image is very small and you need to increase its size during conversion.
Please try the the code suggested by the @Professionalize.Discourse or as described here:

The only thing I recommend to change is the size multiplier:

rasterizationOptions.setPageWidth(image.getWidth() * 8);
rasterizationOptions.setPageHeight(image.getHeight() * 8);

Also, I may suggest adding a smoothing mode:

rasterizationOptions.setSmoothingMode(SmoothingMode.AntiAlias);
or
rasterizationOptions.setSmoothingMode(SmoothingMode.HighQuality);

This works a bit slower, but will grant you a less pixelized output.
I’ll attach two examples: without and with smoothing.
image292.png (3.6 KB)
image292aa.png (11.2 KB)