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:
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 ?
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.
NotImplementedException.zip (31.4 KB) jUnitTest with clean implementation of using Aspose.Imaging.
An Exception occurred in line:65 when calling .resize() method.
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.
This is wrong suggestion ! Already checked it before !
In this case will resize raster image after converting in PNG format.
The quality of vector image will lost if coefficient of scaling too much.
The main sense of using SVG is scaling image BEFORE it will rasterized to PNG or other format and in this case could be saved quality of image. Look into example of code in this topic please:
and it is working same way. Yes, it is working, but working wrong.
It resize image after rasterize and lost the quality of image.
But right way is resize vector image before it will rasterize !
We are sorry for your inconvenience. We are verifying it further on our end and will share feedback with you ASAP. We request for your patience in this regard.
Sorry for my perseverance !
Of course, I understand, that it is not simple to make so flexible method, which will working for all formats.
I will waiting for results and I wish luck to you.
P.S. I did not tested on versions high, than 19.4.
Tell me please, if exists a possible, that you fixed it in newer versions ?
We’ve double checked the issue and found that current implementation works well when up-scaling with scale factor 10 and more, but loses quality with smallest scale factor values. Just to ensure, that we’re on the same page, can you please share the required logo width and height. We have also added the issue with ID IMAGINGJAVA-1431 to support native Svg resize in the future releases as well.
Well, originally I have SVG image with size 165x40.
I have not possible to define factor of scale because I am using Template for Documents,
which customers creating themselves and I can retrieve only width and height.
But, usually it resizing to resolution around of 350x85 pixels.
Actually, exists a possible, that it could be resized to 650x155 pixels.
In this topic uploaded archive, which contain source code and sample of SVG image.
If I understood correctly, that vector image after load over
com.aspose.imaging.Image.load(stream);
should be resized using
com.aspose.imaging.Image.resize(width, height);
method without lost quality of image and after that converting to other formats or execute some other activity with this image. Is that correct ?
Thank you for sharing the information. We will get back to you as soon as the concerned IMAGINGJAVA-1431 will be resolved and request for your patience in this regard.
This is the great news. I will try new 19.11 version of Aspose Imaging library in the nearest future.
Actually for now I am using 19.10 version of Aspose Imaging library and I tried your solution.
I found, that your:
method started working much better.
It is looks like in this method you resize first and after that executing image rasterization.
It still a little bit blurred but manipulating of Quality option I reach much better quality.
So, tell me please, do you implemented .resize() method for vector images in Image class ?