Recipe for creating Windows ICO files with ImageMagick?

后端 未结 9 1249
长发绾君心
长发绾君心 2020-12-13 07:18

I would like to create .ico icon for my Windows application dynamically (from the SVG file) by using ImageMagick. How do I do that?

Microsoft lists vari

相关标签:
9条回答
  • 2020-12-13 08:06

    Modifying hnasarat's answer for windows users. The easiest way to is install InkScape and ImageMagick using Chocolatey and then run the following in a batch file. (It is not as flexible as the other answers you just pass in one svg but it pumps out all the favicons recommended in Favicon Cheat Sheet.

    @ECHO off
    
    IF "%1"=="" (
        ECHO You must provide an svg file
        EXIT /b
    ) 
    
    IF NOT EXIST favicons MD favicons
    
    SET "sizes=16 24 32 48 57 64 72 96 120 128 144 152 195 228 256 512"
    
    FOR %%s IN (%sizes%) DO (
        inkscape -z -e favicons/favicon-%%s.png -w %%s -h %%s %1
    )
    
    convert favicons/favicon-16.png favicons/favicon-24.png favicons/favicon-32.png favicons/favicon-48.png favicons/favicon-64.png favicons/favicon.ico
    
    0 讨论(0)
  • 2020-12-13 08:10

    Bash one-liner to convert logo.svg into logo.ico, using Inkscape to export the png images at various sizes:

    eval convert \
      '<(inkscape -e /dev/stderr logo.svg -w '{16,24,32,48,64,128,256}' 2>&1 > /dev/null)' \
      logo.ico
    

    Inspired by Malcolm MacLeod's answer, but avoiding the explicit loop and the temporary files.

    The stderr and redirection is to avoid Inkscape's success message on stdout (“Bitmap saved as: /dev/stdout”) ending up in the image data.

    0 讨论(0)
  • 2020-12-13 08:11
    magick convert in.jpg -define icon:auto-resize=16,48,256 -compress zip out.ico
    

    http://imagemagick.org/script/command-line-options.php#define

    0 讨论(0)
提交回复
热议问题