SVG → PNG conversion. Shells out to rsvg-convert (librsvg). The
binary is part of the librsvg2-bin package on Debian/Ubuntu — if
not installed, rendering returns {:error, :rasterizer_missing} and
refine_og/4 falls back to the input OG map so nothing crashes
user-facing.
A second backend (ImageMagick magick) is wired as a fallback for
hosts without rsvg-convert, but its SVG rendering quality is lower —
prefer rsvg.
Why rsvg-convert
- Best quality / native librsvg renderer.
- Single dependency, very fast (~50ms per 1200×630).
- Drop-in piping: SVG via stdin, PNG via stdout.
Summary
Functions
Rasterizes the given SVG iodata/binary to a PNG binary.
Reports which rasterizer backend is reachable on this host.
Functions
Rasterizes the given SVG iodata/binary to a PNG binary.
opts:
:width/:height— output size (defaults to the SVG's intrinsic dimensions).:timeout— wallclock ms for the converter, default 5000.
Errors are returned, never raised — the caller decides whether to return a fallback URL or 404.
@spec which_backend() :: :resvg_nif | :resvg_cli | :rsvg | :magick | :none
Reports which rasterizer backend is reachable on this host.
Preference order:
:resvg_nif— the:resvgHex package's NIF (mrdotb/resvg_nif). Precompiled via rustler_precompiled, shipped insidemix deps.get. Zero system-install burden in the common case. This is the default.:resvg_cli—cargo install resvgbinary on PATH. Same renderer but as a subprocess; only used if the NIF isn't available.:rsvg— librsvg2'srsvg-convert. Pipes via stdin/stdout.:magick— ImageMagick. Last-resort fallback.:none— no backend reachable;refine_og/4becomes a pass- through (never crashes).