If you provide these files:
- src/www/logo.dim
- src/www/logo.svg
…and declare that you want a PNG image with the same
basename:
# In Makefile
PNGS += logo
…then Mokvino Web will
generate pub/www/logo.png from
logo.svg as an image with dimensions
specified in logo.dim. For example:
It's possible to leave out one of the dimensions to
let it be computed by the rasterizer.
The conversion is performed by
rasterizer, which is part of
Batik, or by Inkscape, which is the default. You can
change this by setting SVG2PNG=rasterizer
.
There's an easily fixed
bug in the Ubuntu package
libbatik-java, if it reports java.lang.NoClassDefFoundError
. Make sure
that xmlgraphics-commons is included in
the classpath unconditionally:
find_jars commons-logging commons-io xmlgraphics-commons
If you want to create large and small PNGs of a
single SVG, define labels for each size using
SCALES:
SCALES += big
SCALES += small
PNGS += $$(SCALES:%=icons/foo-%)
Then define dimensions for the labelled PNGs:
# In src/www/icons/foo-big.dim
width=32
height=32
# In src/www/icons/foo-small.dim
width=16
height=16
This works by copying the source SVG unchanged to
var/www/icons/foo-small.svg and
var/www/icons/foo-big.svg, from which the
standard rules can convert to PNG.
If you want several images of the same scale to have
the same dimensions, you can create the dimensions
dynamically:
var/www/%-small.dim: src/small.dim
cp --reflink=auto '$$<' '$$@'