Converting WMF (Windows Metafile) images to SVG
I used the following recipe to make Microsoft Office 97 usable on the Web. You can download the result from the Internet Archive.
I have found that the best converters for Windows Metafiles target SVG. They are wmf2svg and LibreOffice Draw. It turns out that 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.) LibreOffice Draw is preferable because it converts complex images with fewer artifacts than wmf2svg. 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 for that 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
Once your images are converted, can optimize them for size with SVGO, although I didn’t do that for the Office 97 clip art.
Tags: command line, graphics, how-to.