Aspose.Imaging issue with resize SVG image


#1

Hello, Aspose Team !

In my Java code, I try to load images, using Aspose.Imaging library.
For reach better quality of generated document we want to use SVG format of image in logo.
The method should read different type of images,
then resize to box of document and reload to BufferedImage for next processing.
I found example of code in your manual for WMF format and implemented the same for SVG format.
Here is my method:

public BufferedImage readToImage(InputStream stream, float width, float height) {
	try (ByteArrayOutputStream output = new ByteArrayOutputStream()) {
		com.aspose.imaging.Image image = com.aspose.imaging.Image.load(stream);
		image.resize(Math.round(width), Math.round(height));
		if (image != null) {
			com.aspose.imaging.imageoptions.PngOptions options = new com.aspose.imaging.imageoptions.PngOptions();
			if (image.getFileFormat() == com.aspose.imaging.FileFormat.Svg) {
				options.setVectorRasterizationOptions(new com.aspose.imaging.imageoptions.SvgRasterizationOptions() {{
					setBackgroundColor(com.aspose.imaging.Color.getTransparent());
					setPageWidth(width);
					setPageHeight(height);
				}});
			}
			if (image.getFileFormat() == com.aspose.imaging.FileFormat.Wmf) {
				options.setVectorRasterizationOptions(new com.aspose.imaging.imageoptions.WmfRasterizationOptions() {{
					setBackgroundColor(com.aspose.imaging.Color.getTransparent());
					setPageWidth(width);
					setPageHeight(height);
				}});
			}
			options.setCompressionLevel(0);
			image.save(output, options);
			options.close();
			image.close();
		}
		return ImageIO.read(new ByteArrayInputStream(output.toByteArray()));
	} catch(Exception fail) {
		logger.error(fail.toString());
		return null;
	}
}

I tried that method with Aspose.Imaging 18.11 version, as well with newest 19.4 version of library,
but unsuccessful, because every time I got an Exception as below:

class com.aspose.imaging.internal.Exceptions.NotImplementedException:
The method or operation is not implemented
com.aspose.imaging.fileformats.svg.SvgImage.resize(Unknown Source)
com.aspose.imaging.Image.resize(Unknown Source)
com.infor.daf.docgen.api.Template.readToImage(Template.java:2038)
...

It is throwing on line: image.resize(Math.round(width), Math.round(height));

Our company have a bought license, but first of all I interesting:
Is the problem with .resize() method still exists in library ?
Or I have implemented something wrong ?


#2

@mvm,

I have observe the sample code shared by you and have observed the information provided as well. I request you to please provide the source file reproducing issue on your end that we may verify on our end to help you further.


#3

NotImplementedException.zip (31.4 KB)
jUnitTest with clean implementation of using Aspose.Imaging.
An Exception occurred in line:65 when calling .resize() method.


#4

@mvm,

Thank you for sharing the details. I have observed the issue and issue with ID IMAGINGJAVA-1309 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.