Reduce SVG File Size in C# - Image Resize API

When you are building software to automate the image creation and manipulation then you prefer an easy-to-install and lightweight library to work with. Fortunately, Aspose.Imaging for .NET offers almost all the features required to make the development smooth and efficient. However, in this blog post, we will implement how to reduce SVG file size in C# programmatically. In addition, you may opt for an online embeddable tool to achieve the same functionality. Therefore, make sure you have setup .NET on your machine to implement the functionality.

The following points will be covered:

  1. Image Resize API Installation
  2. Reduce SVG File Size in C#
  3. Reduce SVG Image Size Online

Image Resize API Installation

Now, for the installation, please download the DLL file or you can install it via NuGet Package Manager by running the following command mentioned below:

Install-Package Aspose.Imaging 
image resize api installation

Reduce SVG File Size in C#

We can now implement the functionality and modify the SVG file size by following the steps mentioned below:

  • Load the source SVG image by calling the Load method of the Image class.
  • The Resize method will modify the dimensions of the image.
  • Instantiate an object of the PngOptions class.
  • Set the vector rasterization options by setting the value of VectorRasterizationOptions property.
  • Invoke the Save method to save the modified image on the disk.

The following code sample demonstrates how to develop an SVG image resizer in C# programmatically:

The output of the above code example is shown in the image below:

modify svg

Reduce SVG Image Size Online

Beside an image resize API, Aspose.Imaging for .NET has also exposed an online tool to reduce SVG image size online in any web browser. Further, it is free and you can use it by just clicking the image below:

reduce svg image size online

Modify SVG - Get a Free License

You can get a free temporary license to try this image resize API without evaluation limitations.

Summing up

Image size programmatic manipulation is considered a heavyweight task. However, Aspose.Imaging for .NET has made this process pretty easy by exposing methods and classes. So, we have gone through how to reduce SVG file size in C#. In addition, you can visit the documentation, API references, and GitHub repo.

Finally, is writing new articles. So, keep visiting us for the latest updates.

Ask a question

You can let us know about your questions or queries on our forum.

Frequently Asked Questions – FAQs

How to edit SVG image online?

You can use this online SVG image resizer. This is quick and requires no subscription.

How to decrease SVG file size?

Aspose.Imaging provides a programmatic solution to modify SVG files. So, please visit this link to learn how to achieve that in .NET.

See Also