We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

SVG to PNG: Resolution not working (C# .NET)

This code doesn’t seem to properly set the resolution of the PNG output. I am new to apose tools. Please advise if I am doing something wrong. I would expect that adjusting the resolution up & down would impact the file size and sharpness

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
    Dim License As Aspose.Imaging.License = New Aspose.Imaging.License()

    Dim docs As String = My.Computer.FileSystem.SpecialDirectories.MyDocuments.ToString

    Dim svg As Aspose.Imaging.FileFormats.Svg.SvgImage = Aspose.Imaging.FileFormats.Svg.SvgImage.Load(docs & "\Profile.SVG")
    Dim pngOptions As Aspose.Imaging.ImageOptions.PngOptions = New Aspose.Imaging.ImageOptions.PngOptions()
    Dim svgOptions As Aspose.Imaging.ImageOptions.SvgRasterizationOptions = New Aspose.Imaging.ImageOptions.SvgRasterizationOptions()

    Dim rs As Aspose.Imaging.ResolutionSetting = New Aspose.Imaging.ResolutionSetting()
    rs.HorizontalResolution = 2400
    rs.VerticalResolution = 2400
    svgOptions.ResolutionSettings = rs

    pngOptions.VectorRasterizationOptions = svgOptions

    svg.Save(docs & "\Profile.PNG", pngOptions)

End Sub


Can you please share source file along with generated result so that we may further investigate to help you out.

AsposeSVG2PNGTest_2019-09-30.zip (4.5 MB)
See attached zip file. copy the 2 files in Docs subfolder to your documents folder.


I have worked with source file and sample project shared by you. A ticket with ID IMAGINGNET-3568 has been created in our issue tracking system for further investigate the issue. This thread has been associated with this ticket, so that you can be automatically notified as soon as this issue is resolved.


Can you please use in PageSize.in SvgRasterizationOptions. I hope the following code will be helpful.

            string baseFolder = "D:";
            string fileName = "profile.svg";
            string inputFileName = Path.Combine(baseFolder, fileName);
            using (Image image = Image.Load(inputFileName))
                SvgRasterizationOptions rasterizationOptions = new SvgRasterizationOptions();
                rasterizationOptions.PageSize = new SizeF(2400,2400);
                image.Save(inputFileName+".png", new PngOptions(){VectorRasterizationOptions = rasterizationOptions});