Recipe for creating Windows ICO files with ImageMagick?

后端 未结 9 1251
长发绾君心
长发绾君心 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:51

    I cleaned up Malcolm's solution, fixed a bug, and also made the script output tiffs so you can run tiff2icns in osx.

    #! /bin/bash
    # converts the passed-in svgs to tiff and ico
    
    if [[ $# -eq 0 ]]; then
        echo "Usage: $0 svg1 [svg2 [...]]"
        exit 0
    fi
    
    temp=$(mktemp -d)
    declare -a res=(16 24 32 48 64 128 256 512)
    for f in $*; do
        mkdir -p $temp/$(dirname $f)
        for r in "${res[@]}"; do
            inkscape -z -e $temp/${f}${r}.png -w $r -h $r $f
        done
        resm=( "${res[@]/#/$temp/$f}" )
        resm=( "${resm[@]/%/.png}" )
        for filetype in ico tiff; do
            convert "${resm[@]}" ${f%%.*}.$filetype
        done
    done
    rm -rf $temp
    

提交回复
热议问题