SVG files in TPC

PET TAC data can be plotted in SVG format in several tools available for data analysis in Turku PET Centre.

Scalable Vector Graphics files can be viewed or printed with any up-to-date web browser, including Internet Explorer version 9. LibreOffice can be used to create and edit SVG. Google Drawings can be saved as SVG. Also image/graphics editor programs, such as the free Inkscape, can be used to open (and edit) SVG files.

Alternatively, SVG files can be converted to other graphics formats, for example using on-line tools, such as Go2Convert, or with Inkscape. Software for viewing GIF, JPG, and PNG formats are available in every computer, and these formats can be added to MS Word and PowerPoint documents.

If more than one or two SVG files need to be converted, it is recommended to use command-line tools. If you are using Windows, and have Inkscape installed (not the version from from Microsoft Store), you can use batch file svg2png.bat. The command for converting a single SVG file into PNG format in high quality is

C:\Program Files\Inkscape\inkscape.exe -z -e output.png -w 1200 -d 1200 -b white input.svg

In Turku PET Centre you can convert SVG files to PDF or PNG formats with commands svg2pdf or svg2png, respectively:

svg2pdf *.svg


svg2png *.svg

This requires that Batik SVG Toolkit (version 1.7 or later) is installed, since it uses SVG Rasterizer for the conversion.

To further process PNG, JPG or GIF images, install a photo editing software. A free command-line utility ImageMagick will be handy for automated processing of lots of graphics files. As an example, four PNG images can be joined together into a 2x2 matrix with command

magick montage +frame +shadow +label -tile 2x2 -geometry 100%x100%+0+0 img1.png img2.png img3.png img4.png joined.png

Inside Windows batch file you may need to escape the percent signs and call it like this

call magick montage -tile 2x2 -geometry 100%%%"x"100%%%+20+50 img?.png joined.png

In the example above, the '20' and 50' in the geometry parameter sets 20 pixel horizontal and 50 pixel vertical margin between the images.

With ImageMagick you can even make a movie of png (or other format) images, for example:

magick convert -background white -alpha background -delay 100 -size 400x400 xc:white -dispose previous *.png movie.mpeg

For further instructions, see the page on ImageMagick command-line processing.

To make a simple gallery of SVG plots for viewing in web browser, you can use htmlgall; go to the directory where the SVG files are located, and, for example, enter command:

htmlgall gallery.html *.svg

and double-click the created page, gallery.html.

See also:

More reading:

Cagle K, Bellamy-Royds A, Storey D: Using SVG with CSS3 and HTML5 - Vector Graphics for Web Design. O'Reilly Media, 2017.

Eisenberg J. Bellamy-Royds A: SVG Essentials - Producing Scalable Vector Graphics with XML, 2nd ed., O'Reilly Media, 2014.

Hiitola B: Inkscape Beginner's Guide. Packt Publishing, 2012. ISBN 978-1-84951-720-1.

Tags: , ,

Updated at: 2020-06-30
Created at: 2011-10-19
Written by: Vesa Oikonen