As mentioned yesterday, the source files for the illustrations in my Sound Actions book are available on GitHub in the form of LibreOffice Draw files (ODG).

Draw may be less powerful but much easier to work with than more advanced line art software, such as Inkscape. One of the nice things about the LibreOffice package is its scripting possibilities. While working on my book, I wrote a shell script that would read all the ODG files in a folder and convert them to PDF and PNG files:


for i in *.odg; 
do name=`echo $i | cut -d'.' -f1`; 
libreoffice --headless --convert-to pdf $i
pdfcrop "$name.pdf"
rm "$name.pdf"

for i in *.pdf; 
do name=`echo $i | cut -d'.' -f1`; 
convert -density 300 "$i" "$name.png"; 

Notice that I use a small terminal program called pdfcrop to remove all the whitespace around the exported PDF. By default, LibreOffice exports full pages, which in most cases will result in much whitespace around figures. So, I crop the files automagically before exporting PNG files.

This script saved me much time when working on my manuscript. I could edit some of the illustrations (even programmatically, more on that later) and then use the script to export updated images in the relevant file format.