One of the reasons for the popularity of SVG images is the retainment of quality when enlarged. JPG images are also one of the commonly used image formats and have huge compatibility support from almost every third-party application. So there is a large requirement to convert images from one format to another comes. This article discusses how to convert SVG vector graphics to JPG images using C#.

Convert SVG to JPG using C# (Grayscale, Rotate, Flip, Bright Watermark)

.NET API to Convert Images

GroupDocs.Conversion provides .NET developers with its API to convert image formats into various other formats. The converted image can be treated during the conversion process using the available multiple advanced options. I will use its GroupDocs.Conversion for .NET to convert the SVG vector image into a JPG image.

You can download the DLLs or MSI installer from the downloads section or install the API by adding its package to your .NET application via NuGet.

PM> Install-Package GroupDocs.Conversion

Running examples for its features are also available on GitHub. Visit its documentation and API Reference for guidance.

Convert SVG to JPG Image using C#

The basic conversion of vector graphics into JPG format is quite simple. It can be performed using the default conversion settings. The following steps show how to convert the SVG image into JPG using C#.

  • Load the SVG file using the Converter class.
  • Prepare the image conversion options.
  • Set the conversion file type as JPG.
  • Invoke Convert method with prepared options to convert SVG into JPG.

The following C# source code converts the SVG into a JPG image.

SVG to JPG Image using Advanced Options using C#

There are many customization options available that can be applied to JPG output while converting the vector graphics. The following are some of the properties that you can tweak while SVG to JPG conversion:

  • Brightness
  • Contrast
  • Gamma
  • Grayscale
  • Flip Mode (Horizontal / Vertical)
  • Rotation Angles
  • Height
  • Width
  • Watermark

The following steps show how to convert an SVG image and further apply customizations while converting it into a JPG image using C#.

  • Load the SVG graphic using the Converter class.
  • Prepare the image conversion options.
  • Set the conversion file type as JPG.
  • Set other customization options and adjust their values accordingly.
  • Convert to JPG image using the Convert method with prepared options.

The following source code adds customization during SVG to JPG conversion using C#. You may apply any of these effects or in combination to get the desired JPG output.

Get a Free API License

You can get a free temporary license to use the API without the evaluation limitations.

Conclusion

To sum up, we discussed converting SVG vectors into JPG format within .NET applications. We also learned to flip, rotate or watermark SVG files when converted to JPG using C#. Additionally, we tweaked the gamma, brightness, and grayscale options.

Try building your own image conversion .NET application, you may learn more about the document and image conversion .NET APIs from the documentation. Contact us for any query via the forum.

See Also