Converting WMF (Windows Metafile) images

I have found that the best converters for Windows Metafiles target SVG. They are wmf2svg and LibreOffice Draw. You can use the latter from the command line for batch conversion. (But be careful not to have any LibreOffice instances open! It seems to prevent the file from opening in a “headless” instance.) Wmf2svg may introduce artifacts to a complex image; LibreOffice Draw doesn't seem to. While wmf2svg preserves the canvas size of the original image, LibreOffice does not. You must crop the image with another SVG tool like Inkscape after conversion. The commands you want are:

libreoffice --headless --convert-to svg Popular/tennis.wmf
# Inkscape 0.x
inkscape --with-gui --verb FitCanvasToDrawing --verb FileSave --verb FileQuit tennis.svg
# Inkscape 1.x
inkscape --with-gui --verb 'FitCanvasToDrawing;FileSave;FileQuit' tennis.svg

You can then optimize your images for size with SVGO.

Tags: command line, graphics, how-to.