Working with SVG Graphics in MediaWiki

From Zanecorpwiki

Jump to: navigation, search

It's likely that MediaWiki will eventually do the very simple stuff required to support SVG directly *and* provide PNGs as a fallback. This wouldn't be very hard to do oneself, but would require code changes. It's astounding it's not here, and half the documents talk as if it can be done or will be done soon, but don't be fooled. It's not actually possible to get MediaWiki to directly display an SVG at the time of this writing (7-7-08).

Even though Firefox and other browsers support SVG natively, there does not appear to be a (-n easy) way to get Mediawiki to display just drop the SVG. Instead, it rasterizes the SVG. To enable this:

  1. make sure ImageMagic (and specifically 'convert') is installed on the host
  2. make sure inkscape is installed on the host
  3. make sure that 'svg' is added to '$wgFileExtensions' (need to add if not already)
  4. make sure '$wgEnableUploads = true;' (should already be in the file, though default is false)
  5. for versions prior to 1.10, make sure '$wgUseImageResize =true;' (should already be in the file)
  6. make sure '$wgUseImageMagic = true;' (may be in file, but commented out)
  7. make sure '$wgImageMagicConvertCommand' is set to the path, probably /usr/bin/convert
  8. set '$wgAllowTitlesInSVG = true;'
  9. set '$wgSVGConverter = inkscape;'
  10. set '$wgSVGConverterPath = /opt/gnome/bin;' idiomatic: it's not the path to the command (i.e., the results of 'which rsvg'), but is rather the path to the directory containing the command

In a capable browser, you can get to the SVG by clicking on the thumbnail. Then, from the image page, click on the source link.

The recommended converter is actually rsvg, but I've found that (at least with dia generated svgs), it does a terrible job of placing items. Inkscape is slower, but that only matters once, and does a much better job.

See also Forcing Image Thumbnails to Regenerate in MediaWiki.

Personal tools