iOS脚本生成icon

IconContents(){
cat <./AppIcon.appiconset/Contents.json

    {
        "images": [
            {
                "size": "20x20",
                "idiom": "iphone",
                "filename": "[email protected]",
                "scale": "2x"
            },
            {
                "size": "20x20",
                "idiom": "iphone",
                "filename": "[email protected]",
                "scale": "3x"
            },
            {
                "size": "29x29",
                "idiom": "iphone",
                "filename": "icon-29.png",
                "scale": "1x"
            },
            {
                "size": "29x29",
                "idiom": "iphone",
                "filename": "[email protected]",
                "scale": "2x"
            },
            {
                "size": "29x29",
                "idiom": "iphone",
                "filename": "[email protected]",
                "scale": "3x"
            },
            {
                "size": "40x40",
                "idiom": "iphone",
                "filename": "[email protected]",
                "scale": "2x"
            },
            {
                "size": "40x40",
                "idiom": "iphone",
                "filename": "[email protected]",
                "scale": "3x"
            },
            {
                "size": "60x60",
                "idiom": "iphone",
                "filename": "[email protected]",
                "scale": "2x"
            },
            {
                "size": "60x60",
                "idiom": "iphone",
                "filename": "[email protected]",
                "scale": "3x"
            },
            {
                "size": "20x20",
                "idiom": "ipad",
                "filename": "icon-20-ipad.png",
                "scale": "1x"
            },
            {
                "size": "20x20",
                "idiom": "ipad",
                "filename": "[email protected]",
                "scale": "2x"
            },
            {
                "size": "29x29",
                "idiom": "ipad",
                "filename": "icon-29-ipad.png",
                "scale": "1x"
            },
            {
                "size": "29x29",
                "idiom": "ipad",
                "filename": "[email protected]",
                "scale": "2x"
            },
            {
                "size": "40x40",
                "idiom": "ipad",
                "filename": "icon-40.png",
                "scale": "1x"
            },
            {
                "size": "40x40",
                "idiom": "ipad",
                "filename": "[email protected]",
                "scale": "2x"
            },
            {
                "size": "76x76",
                "idiom": "ipad",
                "filename": "icon-76.png",
                "scale": "1x"
            },
            {
                "size": "76x76",
                "idiom": "ipad",
                "filename": "[email protected]",
                "scale": "2x"
            },
            {
                "size": "83.5x83.5",
                "idiom": "ipad",
                "filename": "[email protected]",
                "scale": "2x"
            },
            {
                "size": "1024x1024",
                "idiom": "ios-marketing",
                "filename": "icon-1024.png",
                "scale": "1x"
            }
        ],
        "info": {
            "version": 1,
            "author": "eddy"
        }
    }
EOF
}

setIconImage(){
    echo "20pt图标生成······"
    sips -z 20 20 $iconfileName --out ./AppIcon.appiconset/icon-20-ipad.png
    sips -z 40 40 $iconfileName --out ./AppIcon.appiconset/[email protected]
    sips -z 40 40 $iconfileName --out ./AppIcon.appiconset/[email protected]
    sips -z 60 60 $iconfileName --out ./AppIcon.appiconset/[email protected]
    echo "29pt图标生成······"
    sips -z 29 29 $iconfileName --out ./AppIcon.appiconset/icon-29-ipad.png
    sips -z 29 29 $iconfileName --out ./AppIcon.appiconset/icon-29.png
    sips -z 58 58 $iconfileName --out ./AppIcon.appiconset/[email protected]
    sips -z 58 58 $iconfileName --out ./AppIcon.appiconset/[email protected]
    sips -z 87 87 $iconfileName --out ./AppIcon.appiconset/[email protected]
    echo "40pt图标生成······"
    sips -z 40 40 $iconfileName --out ./AppIcon.appiconset/icon-40.png
    sips -z 80 80 $iconfileName --out ./AppIcon.appiconset/[email protected]
    sips -z 120 120 $iconfileName --out ./AppIcon.appiconset/[email protected]
    echo "60pt图标生成······"
    sips -z 120 120 $iconfileName --out ./AppIcon.appiconset/[email protected]
    sips -z 180 180 $iconfileName --out ./AppIcon.appiconset/[email protected]
    echo "76pt图标生成······"
    sips -z 76 76 $iconfileName --out ./AppIcon.appiconset/icon-76.png
    sips -z 152 152 $iconfileName --out ./AppIcon.appiconset/[email protected]

    echo "83.5pt图标生成······"
    sips -z 167 167 $iconfileName --out ./AppIcon.appiconset/[email protected]

    echo "1024pt图标生成······"
    sips -z 1024 1024 $iconfileName --out ./AppIcon.appiconset/icon-1024.png
}
mkdir AppIcon.appiconset
if [ -n "$1" ] ; then
   iconfileName=$1
else
    echo "icon不能为空"
   exit 1
fi
IconContents
setIconImage

mv -f AppIcon.appiconset "$x"

你可能感兴趣的:(iOS脚本生成icon)