Related blog post: Convert SVG to PNG using C#
Last active
March 5, 2026 16:08
-
-
Save GroupDocsGists/670601297e7b4a6453acc5b7c2418fb6 to your computer and use it in GitHub Desktop.
Convert SVG to PNG using C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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