2 issues with Svg load and save

Hello,
Kindly review my attached samples, source is my source image, loaded into Photoshop and saved as photoshop.png, also loaded into Aspose Imaging and saved as aspose.png
Compare 2 pngs made with Photoshop and Aspose, size and background transparency is lost in aspose.
Also, if we immediately reload the png made with Aspose into Aspose again and save it back as Svg, the result is very different as the source Svg, is that normal?
Thanks :slight_smile:
Documents.zip (75.8 KB)

oops, the worst issue is that Anti-Aliasing is not applied when saving!

See here:

Aspose Words when saving as images such as Png, has this option to enable anti-aliasing, but not Imaging?!

@australian.dev.nerds Thank you for your interest in our product. We will investigate this matter and provide feedback.

@australian.dev.nerds You can use the following code snippet to save an SVG image, preserving transparency and enabling anti-aliasing:

using (Image image = Image.Load(sourceFile))
{
    SvgRasterizationOptions svgRasterizationOptions = new SvgRasterizationOptions();
    svgRasterizationOptions.PageWidth = image.Width;
    svgRasterizationOptions.PageHeight = image.Height;
    svgRasterizationOptions.BackgroundColor = Color.Transparent;
    svgRasterizationOptions.SmoothingMode = SmoothingMode.AntiAlias;

    PngOptions pngOptions = new PngOptions()
    {
        ColorType = PngColorType.TruecolorWithAlpha,
        VectorRasterizationOptions = svgRasterizationOptions,
    };

    image.Save(outputFile, pngOptions);
}
1 Like

Hello and thanks for your kind help

So I can use RasterizationOptions.SmoothingMode for all other images that has this property as well, great.

Can you please be so kind and shed light on this:

https://reference.aspose.com/imaging/net/aspose.imaging/smoothingmode/

Question1: Invalid -1 ???!!! Why someone should set it?! What’s that for?

Question2: To set nothing, both Default 0 and None 3 seems the same, confusing for the developer, can you check the internal code to see the difference? If the same, why not remove None 3 to simplify it?

Question3: Can we use both HighQuality and AntiAlias together? Is this usage valid:

PngOptions.VectorRasterizationOptions.SmoothingMode = Aspose.Imaging.SmoothingMode.AntiAlias
PngOptions.VectorRasterizationOptions.SmoothingMode = Aspose.Imaging.SmoothingMode.HighQuality

Or must be used like this:

PngOptions.VectorRasterizationOptions.SmoothingMode = Aspose.Imaging.SmoothingMode.AntiAlias OR Aspose.Imaging.SmoothingMode.HighQuality

Thanks.

Does it also apply to Psd like this:

Dim MyOptions As New Aspose.Imaging.ImageOptions.VectorRasterizationOptions
MyOptions.BackgroundColor = Aspose.Imaging.Color.Transparent
PsdOptions.VectorRasterizationOptions = MyOptions

@australian.dev.nerds As the name suggests, VectorRasterizationOptions should only be applied to vector image formats, such as SVG. They have no effect on operations between raster image formats. The Aspose.Imaging.SmoothingMode is implemented to be compatible with System.Drawing.Drawing2D.SmoothingMode. The options Default, None, and HighSpeed are equivalent, specifying rendering without smoothing. Meanwhile, AntiAlias and HighQuality are equivalent, specifying rendering with smoothing. For any questions regarding these enum fields, please refer to Microsoft.