Skip to content

Convert images

Manfredi Marceca edited this page Mar 24, 2025 · 1 revision

Some image formats are not supported depending on the output document, e.g.

  • WEBP, AVIF in DOCX
  • SVG, GIF, TIFF in RTF
  • TIFF, WMF, EMF when viewing Markdown in a web browser.

These images can be automatically converted to PNG if you install and configure an extra NuGet package (DocSharp.ImageSharp or DocSharp.SystemDrawing). Alternatively, you can create a custom implementation of IImageConverter.

Difference between built-in image converters:

  • DocSharp.ImageSharp:
    • Uses ImageSharp and VectSharp
    • Cross-platform and fully managed (no native dependencies)
    • Supports JPEG, GIF, PNG, TIFF, BMP, WEBP, SVG (possibly ICO and other formats in a future ImageSharp release); metafiles are not supported
  • DocSharp.SystemDrawing
    • Uses System.Drawing.Common and SVG.NET
    • Supported on Windows only (.NET Framework or net8.0-windows / net9.0-windows)
    • Supports JPEG, GIF, PNG, TIFF, BMP, WMF, EMF, SVG

How to use:

  1. Install the DocSharp.ImageSharp or DocSharp.SystemDrawing package
  2. Set the ImageConverter property on the desired converter:
var converter = new DocxToMarkdownConverter()
{
     // ...
     ImageConverter = new ImageSharpConverter() // or new SystemDrawingConverter()
};
var converter = new DocxToRtfConverter()
{
     // ...
     ImageConverter = new ImageSharpConverter() // or new SystemDrawingConverter()
};
var converter = new MarkdownConverter()
{
     // ...
     ImageConverter = new ImageSharpConverter() // or new SystemDrawingConverter()
};
Clone this wiki locally