Free Support Forum - aspose.com

Resizing image

I’m trying to take a svg image, and scale it to a desired size. No matter what I do, It does not appear to resize. Hopefully you can point out my issue quickly.

    public static System.Drawing.Image ConvertToImage(string svg, int width, int height)
    {
        SetLicense();
        using (var stream = new MemoryStream(Encoding.ASCII.GetBytes(svg)))
        {
            using (Aspose.Imaging.FileFormats.Svg.SvgImage svgImage = (Aspose.Imaging.FileFormats.Svg.SvgImage)Aspose.Imaging.Image.Load(stream))
            {
                Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions
                                                                                           {
                                                                                               BackgroundColor = Aspose.Imaging.Color.White,
                                                                                               PageSize = svgImage.Size,
                                                                                               SmoothingMode = Aspose.Imaging.SmoothingMode.AntiAlias,
                                                                                               TextRenderingHint = Aspose.Imaging.TextRenderingHint.AntiAlias,
                                                                                               //ScaleX = (float) height / svgImage.Height,
                                                                                               //ScaleY = (float) height / svgImage.Height
                                                                                           };
                rasterizationOptions.PageSize = new Aspose.Imaging.SizeF(svgImage.Width* (float)height / svgImage.Height, svgImage.Height* (float)height / svgImage.Height);

                svgImage.ResizeHeightProportionally(height);
                svgImage.Resize(width,height/50);
                Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions { VectorRasterizationOptions = rasterizationOptions };

                MemoryStream imgMemoryStream = new MemoryStream();
                svgImage.Save(imgMemoryStream, saveOptions);

                return System.Drawing.Image.FromStream(imgMemoryStream) ;
            }

@gmitchell.ipipeline

I suggest you to please visit the following thread for your convenience to see how to resize the SVG.