SVG file size is huge compared to PNG


#1

Hi there,

We are seeing issue related to file size for EMF to SVG converted file compared to EMF to PNG converted file. Could you please check and let us know.

Code Snippet :

String dataDir = “C:\emf-with-svg-content\”;
Image image = Image.load(dataDir + “image9.emf”, new MetafileLoadOptions(true));
try {
// Create an instance of EmfRasterizationOptions class and set
// different options
final EmfRasterizationOptions emfRasterizationOptions = new EmfRasterizationOptions();
emfRasterizationOptions.setPageWidth(image.getWidth());
emfRasterizationOptions.setPageHeight(image.getHeight());

// call the save method and pass instance of SvgOptions class to
// convert it to SVG format.
image.save(dataDir + "image9.svg", new SvgOptions() {
	{
		setVectorRasterizationOptions(emfRasterizationOptions);
		
	}
});

} finally {
image.dispose();
}

Thanks,
Ganesh

EMF’s size.zip (1.6 MB)


#2

@gm69267,

I have worked with source file and sample code shared by you using Aspose.Imaging 18.9 and generated both format PNG and SVG. I like to share that i don’tResult.zip (1.7 MB)
see much difference in size of both formats. I have also shared my generated output with you for your kind reference. I also like to inform that SVG format is xml, which can not be compressed by the nature of the format.


#3

Hi @Adnan.Ahmad,

Please refer the latest attachment. I could see the image sizes as below.

EMF size -> 1201 KB
SVG size -> 972 KB
PNG size -> 523 KB

There is huge difference between the sizes.

Thanks,EMF’s size_lates.zip (1.9 MB)


#4

@gm69267,

I have observed your comments. You may use below code snippet to reduce file size of PNG. For SVG like i said in my previous reply SVG format is xml, which can not be compressed by the nature of the format.

image.save(path+ “imagepng.png”, new PngOptions() { FilterType = PngFilterType.Adaptive