svgimagemagickfavicongraphicsmagickico

How to convert an image file from SVG to a multi-size ICO without blur (sharp)


I've been using ImageMagick, but it produces a very blurry result.

convert -density 300 ../images/favicons/procensus.svg -background transparent -colors 256 -define icon:auto-resize favicon2.ico

It seems to be rendering the image at 300 density, then resizing that with a Gaussian filter for all the other sizes in the icon.

What I actually want it to do is re-render with shape-rendering="crispEdges" at each pixel size in the favicon.

I want ImageMagick (or whatever other tool) to re-render the SVG at each provided density of .ico.

Note that this tool should only be a tool I can use at package build time: an open-source piece of installable software for Linux.


Solution

  • I've got it working configuring shape-rendering="crispEdges" and doing:

    sudo apt install libbatik-java
    rasterizer favicon.svg -d favicon-16.png -h 16 -w 16
    rasterizer favicon.svg -d favicon-32.png -h 32 -w 32
    rasterizer favicon.svg -d favicon-48.png -h 48 -w 48
    rasterizer favicon.svg -d favicon-64.png -h 64 -w 64
    
    convert favicon-16.png favicon-32.png favicon-48.png favicon-64.png favicon.ico
    

    But it looks like image magick doesn't support that attribute.

    I'm still looking for more elegant answers.