Recipe for creating Windows ICO files with ImageMagick?

后端 未结 9 1253
长发绾君心
长发绾君心 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 07:55

    Building on all previous answers and correcting the following mistakes:

    • Don't use -color=256, as you need 32-bit color versions for all sizes with modern Windows versions (Vista+)
    • Necessary sizes in Windows are 16, 24, 32, 48, 64, 128, 256. Most scripts forgot those. I am unsure if 96 is really needed, but it doesn't hurt.
    • You need to include 4-bit and 8-bit palette versions for the sizes 16, 24, 32 and 48 (apparently to support Remote Desktop applications in particular)

    All in one bash script (starting from logo.svg and producing logo.ico):

    #!/bin/bash
    
    for size in 16 24 32 48 64 96 128 256; do
        inkscape -z -e $size.png -w $size -h $size logo.svg >/dev/null 2>/dev/null
    done
    
    for size in 16 24 32 48; do
    
      convert -colors 256 +dither $size.png png8:$size-8.png
      convert -colors 16  +dither $size-8.png $size-4.png
    
    done
    
    convert 16.png 24.png 32.png 48.png 16-8.png 24-8.png 32-8.png 48-8.png 16-4.png 24-4.png 32-4.png 48-4.png 64.png 96.png 128.png 256.png logo.ico
    
    rm 16.png 24.png 32.png 48.png 16-8.png 24-8.png 32-8.png 48-8.png 16-4.png 24-4.png 32-4.png 48-4.png 64.png 96.png 128.png 256.png 
    

提交回复
热议问题