Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Last active March 5, 2026 16:08
Show Gist options
  • Select an option

  • Save GroupDocsGists/670601297e7b4a6453acc5b7c2418fb6 to your computer and use it in GitHub Desktop.

Select an option

Save GroupDocsGists/670601297e7b4a6453acc5b7c2418fb6 to your computer and use it in GitHub Desktop.
Convert SVG to PNG using C#
// How to convert SVG file into PNG format in C# using .NET Conversion API with default options
using (Converter converter = new Converter("path/vector-graphics.svg"))
{
ImageConvertOptions options = new ImageConvertOptions
{
Format = ImageFileType.Png
};
converter.Convert("path/svg-to-png.png", options);
}
// Convert SVG file into PNG format in C# using various customizations
using (Converter converter = new Converter("path/vector-graphics.svg"))
{
ImageConvertOptions options = new ImageConvertOptions
{
Format = ImageFileType.Png,
FlipMode = ImageFlipModes.FlipY,
RotateAngle = 45,
Grayscale = true
/*
Brightness = 50,
Contrast = 50,
Gamma = 0.5F,
*/
};
// Applying Watermark on the converted image
WatermarkOptions watermark = new WatermarkTextOptions("Watermark")
{
Color = Color.Blue,
Width = 150,
Height = 150,
Background = false,
Top = 50,
Left = 50,
RotationAngle = -45,
Transparency = 50,
};
options.Watermark = watermark;
converter.Convert("path/svg-to-png-customized.png", options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment