Exception "Image saving failed" when converting EMF to SVG using Aspose.Imaging for Java

Hi,

We have tried to convert EMF or WMF to SVG file using Aspose.Imaging 3.7 library, but we are getting below exception when we execute the code.

According to 3.7 release note we can convert EMF to SVG. Can you please check and provide us the solution.

class com.aspose.imaging.coreexceptions.ImageSaveException: Image saving failed. ---> classcom.aspose.imaging.internal.Exceptions.ArgumentException: Cannot save to the specified format as it is not supported at the moment.

Parameter name: optionsBase

com.aspose.imaging.Image.a(Unknown Source)
com.aspose.imaging.Image.save(Unknown Source)
com.aspose.imaging.Image.save(Unknown Source)

Thanks and Regards,
Pankaj

Hi Pankaj,

Thank you for your inquiry.

This is to update you that EMF to SVG and WMF to SVG format conversion features are not supported. Tickets for these features have already been created into our system with IDs IIMAGINGJAVA-94 & IMAGINGJAVA-527. Details of the ticket IDs are given below.

IMAGINGJAVA-94: Support for EMF to SVG conversion
IMAGINGJAVA-527: Support for WMF to SVG conversion

Furthermore Aspose.Imaging for Java 3.7.9 release notes indicate that support for SVG to raster image conversion is available.

Hi,



Update to above, now we tried using aspose imaging java lib version aspose-imaging-16.12-jdk16.jar. With this we are able to convert some “emf” images to “svg” but some images are getting failed with below Exception. We are not able to track the root cause for this exception as the height and width of the images that we’re able to convert was much smaller than the image for which we are getting this exception. Can you please let us know what could be the possible root cause for this exception.



Thanks and Regards,

Pankaj









EXCEPTION LOGS:





class com.aspose.imaging.coreexceptions.ImageSaveException: Image saving failed. —> class com.aspose.imaging.coreexceptions.ImageSaveException: Image export failed. —> java.lang.IllegalArgumentException: Dimensions (width=8388608 height=8388608) are too large

— End of inner exception stack trace —

com.aspose.imaging.Image.a(Unknown Source)

com.aspose.imaging.Image.save(Unknown Source)

com.aspose.imaging.Image.save(Unknown Source)

com.csg.cs.sample.imageconversion.AsposeEMFtoSVG.main(AsposeEMFtoSVG.java:62)

— End of inner exception stack trace —

com.aspose.imaging.Image.save(Unknown Source)

com.aspose.imaging.Image.save(Unknown Source)

com.csg.cs.sample.imageconversion.AsposeEMFtoSVG.main(AsposeEMFtoSVG.java:62)

at com.aspose.imaging.Image.save(Unknown Source)

at com.aspose.imaging.Image.save(Unknown Source)

at com.csg.cs.sample.imageconversion.AsposeEMFtoSVG.main(AsposeEMFtoSVG.java:62)

Caused by: class com.aspose.imaging.coreexceptions.ImageSaveException: Image export failed. —> java.lang.IllegalArgumentException: Dimensions (width=8388608 height=8388608) are too large

— End of inner exception stack trace —

com.aspose.imaging.Image.a(Unknown Source)

com.aspose.imaging.Image.save(Unknown Source)

com.aspose.imaging.Image.save(Unknown Source)

com.csg.cs.sample.imageconversion.AsposeEMFtoSVG.main(AsposeEMFtoSVG.java:62)

at com.aspose.imaging.Image.a(Unknown Source)

… 3 more

Caused by: java.lang.IllegalArgumentException: Dimensions (width=8388608 height=8388608) are too large

at java.awt.image.SampleModel.(SampleModel.java:130)

at java.awt.image.MultiPixelPackedSampleModel.(MultiPixelPackedSampleModel.java:147)

at java.awt.image.MultiPixelPackedSampleModel.(MultiPixelPackedSampleModel.java:107)

at java.awt.image.Raster.createPackedRaster(Raster.java:846)

at java.awt.image.Raster.createPackedRaster(Raster.java:588)

at java.awt.image.BufferedImage.(BufferedImage.java:450)

at com.aspose.imaging.internal.Y.m$a.(Unknown Source)

at com.aspose.imaging.internal.Y.m.a(Unknown Source)

at com.aspose.imaging.internal.eU.p.a(Unknown Source)

at com.aspose.imaging.internal.eR.a.b(Unknown Source)

at com.aspose.imaging.internal.eT.a.g(Unknown Source)

at com.aspose.imaging.internal.eT.a.f(Unknown Source)

at com.aspose.imaging.internal.eT.a.a(Unknown Source)

at com.aspose.imaging.internal.eR.d.c(Unknown Source)

at com.aspose.imaging.internal.eR.c.a(Unknown Source)

at com.aspose.imaging.internal.ea.m.a(Unknown Source)

at com.aspose.imaging.internal.ea.m.a(Unknown Source)

at com.aspose.imaging.internal.ea.m.a(Unknown Source)

at com.aspose.imaging.internal.ea.m.a(Unknown Source)

at com.aspose.imaging.internal.ea.w.b(Unknown Source)

at com.aspose.imaging.internal.ea.a.a(Unknown Source)

at com.aspose.imaging.internal.ea.a.export(Unknown Source)

… 4 more

Hi Pankaj,

Thank you for your inquiry.

This is to update you that we need the problematic input file to properly investigate the issue and to reproduce it at our end. Please forward us the sample input files and the code snippet that you are using. We will investigate the issue and update you with our findings via this forum thread.

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

Hello there,

We are having issue with respect to image conversion from EMF to SVG. We are using the below code snippet and the exception details are below.

We are using aspose-imaging-16.10-jdk16.jar for the conversion. Please suggest if we are missing something here.

Code Snippet.

public static void main(String… args) throws Exception {

	String dataDir = "C:\\temp\\";
	
	Image image = Image.load(dataDir + "image7.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 + "image7.svg", new SvgOptions() {
			{
				setVectorRasterizationOptions(emfRasterizationOptions);
				
			}
		});
	} finally {
		image.dispose();
	}
            //ExEnd:ConvertEMFtoSVG
}

Exception :

Exception in thread “main” class com.aspose.imaging.coreexceptions.ImageSaveException: Image saving failed. —> class com.aspose.imaging.coreexceptions.ImageSaveException: Image export failed. —> java.lang.IllegalArgumentException: Dimensions (width=8388608 height=8388608) are too large
— End of inner exception stack trace —
com.aspose.imaging.Image.a(Unknown Source)
com.aspose.imaging.Image.save(Unknown Source)
com.aspose.imaging.Image.save(Unknown Source)
com.citi.icg.rendition.webservice.test.TestEMFtoPNG.main(TestEMFtoPNG.java:29)
— End of inner exception stack trace —
com.aspose.imaging.Image.save(Unknown Source)
com.aspose.imaging.Image.save(Unknown Source)
com.citi.icg.rendition.webservice.test.TestEMFtoPNG.main(TestEMFtoPNG.java:29)
at com.aspose.imaging.Image.save(Unknown Source)
at com.aspose.imaging.Image.save(Unknown Source)
at com.citi.icg.rendition.webservice.test.TestEMFtoPNG.main(TestEMFtoPNG.java:29)
Caused by: class com.aspose.imaging.coreexceptions.ImageSaveException: Image export failed. —> java.lang.IllegalArgumentException: Dimensions (width=8388608 height=8388608) are too large
— End of inner exception stack trace —
com.aspose.imaging.Image.a(Unknown Source)
com.aspose.imaging.Image.save(Unknown Source)
com.aspose.imaging.Image.save(Unknown Source)
com.citi.icg.rendition.webservice.test.TestEMFtoPNG.main(TestEMFtoPNG.java:29)
at com.aspose.imaging.Image.a(Unknown Source)
… 3 more
Caused by: java.lang.IllegalArgumentException: Dimensions (width=8388608 height=8388608) are too large
at java.awt.image.SampleModel.(SampleModel.java:130)
at java.awt.image.MultiPixelPackedSampleModel.(MultiPixelPackedSampleModel.java:147)
at java.awt.image.MultiPixelPackedSampleModel.(MultiPixelPackedSampleModel.java:107)
at java.awt.image.Raster.createPackedRaster(Raster.java:846)
at java.awt.image.Raster.createPackedRaster(Raster.java:588)
at java.awt.image.BufferedImage.(BufferedImage.java:450)
at com.aspose.imaging.internal.aa.m$a.(Unknown Source)
at com.aspose.imaging.internal.aa.m.a(Unknown Source)
at com.aspose.imaging.internal.eV.p.a(Unknown Source)
at com.aspose.imaging.internal.eS.a.b(Unknown Source)
at com.aspose.imaging.internal.eU.a.g(Unknown Source)
at com.aspose.imaging.internal.eU.a.f(Unknown Source)
at com.aspose.imaging.internal.eU.a.a(Unknown Source)
at com.aspose.imaging.internal.eS.d.c(Unknown Source)
at com.aspose.imaging.internal.eS.c.a(Unknown Source)
at com.aspose.imaging.internal.ee.m.a(Unknown Source)
at com.aspose.imaging.internal.ee.m.a(Unknown Source)
at com.aspose.imaging.internal.ee.m.a(Unknown Source)
at com.aspose.imaging.internal.ee.m.a(Unknown Source)
at com.aspose.imaging.internal.ee.w.b(Unknown Source)
at com.aspose.imaging.internal.ee.a.a(Unknown Source)
at com.aspose.imaging.internal.ee.b.a(Unknown Source)
at com.aspose.imaging.internal.dR.b.a(Unknown Source)
at com.aspose.imaging.internal.dR.c.a(Unknown Source)
at com.aspose.imaging.internal.ee.a.export(Unknown Source)
… 4 more
image7.zip (52.9 KB)

@gmusturi,

I have observed your comments. Can you please try to use Aspose.Imaging latest version 18.6 on your end and share feedback with us if there is still an issue.

@Adnan.Ahmad, I did try the latest aspose-imaging-18.6-jdk16.jar (which I got from - https:// artifact.aspose.com/repo/com/aspose/aspose-imaging/18.6/) and below is the error log trace.

Exception in thread “main” class com.aspose.imaging.coreexceptions.ImageSaveException: Image export failed. —> java.lang.IllegalArgumentException: Dimensions (width=8388608 height=8388608) are too large
— End of inner exception stack trace —
com.aspose.imaging.Image.a(Unknown Source)
com.aspose.imaging.Image.save(Unknown Source)
com.aspose.imaging.Image.save(Unknown Source)
com.citi.icg.rendition.webservice.test.TestEMFtoPNG.main(TestEMFtoPNG.java:29)
at com.aspose.imaging.Image.a(Unknown Source)
at com.aspose.imaging.Image.save(Unknown Source)
at com.aspose.imaging.Image.save(Unknown Source)
at com.citi.icg.rendition.webservice.test.TestEMFtoPNG.main(TestEMFtoPNG.java:29)
Caused by: java.lang.IllegalArgumentException: Dimensions (width=8388608 height=8388608) are too large
at java.awt.image.SampleModel.(SampleModel.java:130)
at java.awt.image.MultiPixelPackedSampleModel.(MultiPixelPackedSampleModel.java:147)
at java.awt.image.MultiPixelPackedSampleModel.(MultiPixelPackedSampleModel.java:107)
at java.awt.image.Raster.createPackedRaster(Raster.java:846)
at java.awt.image.Raster.createPackedRaster(Raster.java:588)
at java.awt.image.BufferedImage.(BufferedImage.java:450)
at com.aspose.imaging.internal.P.m$a.(Unknown Source)
at com.aspose.imaging.internal.P.m.a(Unknown Source)
at com.aspose.imaging.internal.eQ.o.a(Unknown Source)
at com.aspose.imaging.internal.eN.a.b(Unknown Source)
at com.aspose.imaging.internal.eP.a.g(Unknown Source)
at com.aspose.imaging.internal.eP.a.f(Unknown Source)
at com.aspose.imaging.internal.eP.a.a(Unknown Source)
at com.aspose.imaging.internal.eN.d.c(Unknown Source)
at com.aspose.imaging.internal.eN.c.a(Unknown Source)
at com.aspose.imaging.internal.dV.q.a(Unknown Source)
at com.aspose.imaging.internal.dV.q.a(Unknown Source)
at com.aspose.imaging.internal.dV.q.a(Unknown Source)
at com.aspose.imaging.internal.dV.q.a(Unknown Source)
at com.aspose.imaging.internal.dV.D.b(Unknown Source)
at com.aspose.imaging.internal.dV.a.a(Unknown Source)
at com.aspose.imaging.internal.dV.a.export(Unknown Source)
… 4 more

@gmusturi,

I have worked with the image shared by you and have been able to observe the issue. An issue with ID IMAGINGNET-1013 has been created in our issue tracking system to investigate the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will be fixed.