Limited PNG options in Aspose.Imaging vs Aspose.Words in EMF conversion

In Aspose Words, I can do the following

NodeList shapes = converter.getAsposeDoc().selectNodes("//DrawingML");
for (shape : shapes) {

pngSaveOptions= new ImageSaveOptions(SaveFormat.PNG);
pngSaveOptions.setResolution(600);
pngSaveOptions.setUseHighQualityRendering(true);
pngSaveOptions.setDmlRenderingMode(DmlRenderingMode.DRAWING_ML);
pngSaveOptions.setDmlEffectsRenderingMode(DmlEffectsRenderingMode.FINE);
pngSaveOptions.setUseAntiAliasing(true);

shape.getShapeRenderer().save(converter.getImageDirectory().getAbsolutePath() + File.separator + imageName+AsposeImageType.PNG.getExtension(),pngSaveOptions);

}

I get high quality PNG images saved converted from EMF

But, If I already have an EMF saved on the disk (or in a Byte Array), and use the prototypical way of converting it to PNG
try { String filePath = myDir + "image2.emf"; // Load a Metafile in an instance of EmfMetafileImage class EmfMetafileImage metafile = new EmfMetafileImage(filePath); // Save image to Png using PngOptions object metafile.save(myDir + "output.png", new PngOptions()); } catch(Exception ex) { System.out.println(ex.toString()); }

I get a crappy quality PNG file out of it. Why doesn't Imaging have the same options as Words?

What is the best way to match the quality of of Aspose Words conversion process from a Shape object when the Image is already stored in a File or a Byte Array?.


Thanks,
Roshan

Hi Roshan,


Thank you for contacting Aspose support.

Please note, Aspose.Words and Aspose.Imaging provide entirely different set of routines, however, both APIs provide conversion of metafiles to raster image formats therefore it’s an interesting comparison of both APIs to achieve the same qualitative results. We would request you to please provide us you own samples as listed below for further investigation.

  • Source document containing an EMF/Shape
  • An EMF file extracted from the source document
  • A PNG saved directly with Aspose.Words for Java
  • A PNG saved with Aspose.Imaging for Java 2.4.0

Please note that we are asking you to provide the samples because this way we can benchmark the results based on the same samples, and move forward with the investigation to improve the results with Aspose.Imaging for Java API.

In the meanwhile, we have started evaluating your presented scenario on our end while using a few samples of our own, and we will keep you posted with updates in this regard.

Thank you for your quick response.


Here are the four artifacts that you requested.

I couldn’t attach the .emf file as is, so I have renamed the file by appending a fake docx extension. So, remove the extra extension

Hi Roshan,


Many thanks for the samples. We are currently evaluating your provided samples, and we will shortly get back to you with updates in this regard.

Hi again,


Thank you for your patience.

We have logged an appropriate ticket (IMAGING-34553) in our database after evaluating the presented scenario on our end. We have noticed that Aspose.Words’ generated PNG image is better in quality as compared to the Aspose.Imaging’s generated image for the feature of converting metafiles (EMF). Please spare us little more time to analyze the situation and provide the enhancements for this feature with future releases of Aspose.Imaging for Java API. In the meanwhile, we will keep you posted with updates in this regard.

The issues you have found earlier (filed as IMAGING-34553) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi Roshan,


Please note, you may set the resolution for the resultant image while exporting metafiles to raster image formats such as PNG. Please check the following piece of code for better understanding.

Java

EmfMetafileImage metafile = (EmfMetafileImage)Image.load(“aspose_sample.emf”);
PngOptions options = new PngOptions();
// Set the resolution like in Aspose.Words example
options.setResolutionSettings(new ResolutionSetting(600,600));
// Save image to PNG using PngOptions object
metafile.save(“exported.png”, options);
metafile.dispose();

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.