Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
To convert SVG to GIF in C#, load the SVG document or prepare SVG content, create
ImageSaveOptions with ImageFormat.Gif, and call
Converter.ConvertSVG() with the source, options, and output path.
GIF is a simple raster image format often used for lightweight web graphics and legacy compatibility. SVG to GIF conversion is useful when vector graphics must be rendered for systems that expect GIF output, while keeping control over page setup, background color, resolution, and rendering quality.
Before running the examples, install and configure Aspose.HTML for .NET in your project. The complete C# example project is available in the Aspose.HTML for .NET GitHub repository.
The static Converter class provides a compact way to render SVG content to GIF. The example below converts a local SVG file to GIF.
1// Convert SVG to GIF in C#
2
3// Invoke the ConvertSVG() method for SVG to GIF conversion
4Converter.ConvertSVG(Path.Combine(DataDir, "shapes.svg"), new ImageSaveOptions(ImageFormat.Gif), Path.Combine(OutputDir, "convert-with-single-line.gif"));Use this workflow when SVG content is created in code and then saved as a GIF file.
The workflow is:
ImageSaveOptions with ImageFormat.Gif. The default Format value is PNG, so the format must be set for GIF output.Converter.ConvertSVG(content, baseUri, options, outputPath). 1// Convert SVG to GIF using C#
2
3// Prepare SVG code
4string code = "<svg xmlns='http://www.w3.org/2000/svg'>" +
5 "<circle cx ='100' cy ='100' r ='55' fill='pink' stroke='red' stroke-width='8' />" +
6 "</svg>";
7
8// Prepare a path to save the converted file
9string savePath = Path.Combine(OutputDir, "circle.gif");
10
11// Create an instance of the ImageSaveOptions class
12ImageSaveOptions options = new ImageSaveOptions(ImageFormat.Gif);
13
14// Convert SVG to GIF
15Converter.ConvertSVG(code, ".", options, savePath);Use GIF output when compatibility with simple image viewers, lightweight web graphics, or legacy systems matters more than full-color fidelity. GIF is usually not ideal for detailed SVG artwork, gradients, or high-quality previews. For sharper lossless rendering, use SVG to PNG. For smaller previews, use SVG to JPG.
Use ImageSaveOptions when the generated GIF needs custom rendering settings.
To customize SVG to GIF conversion:
SVGDocument.ImageSaveOptions with ImageFormat.Gif.PageSetup, BackgroundColor, resolution, or UseAntialiasing.Converter.ConvertSVG().| Option | Use it to control |
|---|---|
Format | The output image format. The default value is PNG; use ImageFormat.Gif for GIF output. |
BackgroundColor | The color used to fill the image background. The default value is transparent. |
PageSetup | Page size, margins, and page layout settings. |
HorizontalResolution and VerticalResolution | Output resolution values used by the rendering process. The default value is 300 dpi for each property. |
UseAntialiasing | Image rendering quality. Antialiasing is enabled by default. |
Text | Text rendering configuration through TextOptions. |
1// Convert SVG to GIF in C# with custom background, resolution, and antialiasing settings
2
3// Prepare a path to a source SVG file
4string documentPath = Path.Combine(DataDir, "gradient.svg");
5
6// Prepare a path to save the converted file
7string savePath = Path.Combine(OutputDir, "gradient-options.gif");
8
9// Initialize an SVG document from the file
10using SVGDocument document = new SVGDocument(documentPath);
11
12// Initialize ImageSaveOptions. Set up the SmoothingMode, resolutions, and change the background color to AliceBlue
13ImageSaveOptions options = new ImageSaveOptions(ImageFormat.Gif)
14{
15 UseAntialiasing = true,
16 HorizontalResolution = 200,
17 VerticalResolution = 200,
18 BackgroundColor = System.Drawing.Color.AliceBlue
19};
20
21// Convert SVG to GIF
22Converter.ConvertSVG(document, options, savePath);The image below illustrates a GIF rendering result with custom image save options.

Use the online SVG to GIF Converter for quick manual conversion. Use Aspose.HTML for .NET when SVG to GIF conversion must run inside a C# application, service, or document pipeline.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.