Skip to content

(#784) Adds base-uri parameter in rsvg-convert

Daniel Petri Rocha requested to merge danielpetri1/librsvg:base-uri into main

This merge request allows a top level directory to be set as the base location from which relative references for resources are resolved.

This is useful in projects where a directory contains SVGs in a folder that point to images stored elsewhere, as in:

base-directory/
├─ images/
│  ├─ logo.png
├─ svgs/
   ├─ example.svg

Where example.svg is

<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <image xlink:href="file:///absolute/path/base-directory/images/logo.png" height="200" width="200"/>
</svg>

Leaving the parameter out results in the logo not being included in the output PNG.

Example usage:

rsvg-convert -t . --format=png --output=out.png svgs/example.svg
rsvg-convert --top-level-directory /path/to/base-directory/ --format=png --output=out.png svgs/example.svg
Edited by Daniel Petri Rocha

Merge request reports