Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created May 24, 2024 12:29
Show Gist options
  • Save aspose-com-gists/29e0ea7af3eae48e8a502df8d0873e40 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/29e0ea7af3eae48e8a502df8d0873e40 to your computer and use it in GitHub Desktop.
Reduce SVG File Size in C#
namespace CSharp.ResizeSVG
{
class ResizeSVG
{
static void Main(string[] args)
{
// Define the path to the documents directory.
string dataDir = "/Desktop/";
// Load the source SVG image by calling the Load method of the Image class.
using (SvgImage image = (SvgImage)Image.Load(dataDir + "aspose_logo.Svg"))
{
// The Resize method will modify the dimensions of the image.
image.Resize(image.Width * 4, image.Height * 4);
// Instantiate an object of the PngOptions class.
PngOptions pngOptions = new PngOptions();
// Set the vector rasterization options by setting the value of VectorRasterizationOptions property.
pngOptions.VectorRasterizationOptions = new SvgRasterizationOptions();
// Invoke the Save method to save the medified image on the disk.
image.Save(dataDir + "modified.png", pngOptions);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment