target.png: %.png : %.svg convert +antialias -background none "$<" "$@" convert +antialias -background none -density 144 "$<" \ "$(patsubst %.png,%@2.png,$@)" optipng -o7 "$@" "$(patsubst %.png,%@2.png,$@)" email@example.com: target.png
The last line is optional. It tells
make how to build the
@2 file directly in case some other rule asks for it. You will need
ImageMagick and optipng installed for this rule to work.
So, why on earth would someone want to do this? SVG is already a scalable format, so serving it directly would be the best decision surely? Well, usually yes. But in some cases the SVG file is just too large (even after gzipping) to be sent directly. In this case the above Makefile rule jumps in and generates nice, small PNGs.