Flutter mac 应用图标生成脚本

38 min read
echo "***************** 欢迎使用 icns 生成器 *****************"
echo "--> 脚本开始执行 "
echo "--> 请先确保需要转换的PNG图片文件在脚本所在的当前文件夹,并且大小为 1024x1024 ~ "
read -p "--> 请输入需要转换的文件的名称,包含扩展名:" filename
temp_path="$filename.iconset"
echo "--> 创建临时文件夹 $temp_path"
mkdir $temp_path
echo "--> 临时文件夹创建完毕,准备创建临时图片~"
sips -z 16 16     $filename --out $temp_path/icon-16.png
sips -z 32 32     $filename --out $temp_path/[email protected]
sips -z 32 32     $filename --out $temp_path/icon-32.png
sips -z 64 64     $filename --out $temp_path/[email protected]
sips -z 128 128   $filename --out $temp_path/icon-128.png
sips -z 256 256   $filename --out $temp_path/[email protected]
sips -z 256 256   $filename --out $temp_path/icon-256.png
sips -z 512 512   $filename --out $temp_path/[email protected]
sips -z 512 512   $filename --out $temp_path/icon-512.png
sips -z 1024 1024   $filename --out $temp_path/[email protected]

同目录下配置清单文件 contents.json

{
    "images": [
        {
            "size": "16x16",
            "idiom": "mac",
            "filename": "icon-16.png",
            "scale": "1x"
        },
        {
            "size": "16x16",
            "idiom": "mac",
            "filename": "[email protected]",
            "scale": "2x"
        },
        {
            "size": "32x32",
            "idiom": "mac",
            "filename": "icon-32.png",
            "scale": "1x"
        },
        {
            "size": "32x32",
            "idiom": "mac",
            "filename": "[email protected]",
            "scale": "2x"
        },
        {
            "size": "128x128",
            "idiom": "mac",
            "filename": "icon-128.png",
            "scale": "1x"
        },
        {
            "size": "128x128",
            "idiom": "mac",
            "filename": "[email protected]",
            "scale": "2x"
        },
        {
            "size": "256x256",
            "idiom": "mac",
            "filename": "icon-256.png",
            "scale": "1x"
        },
        {
            "size": "256x256",
            "idiom": "mac",
            "filename": "[email protected]",
            "scale": "2x"
        },
        {
            "size": "512x512",
            "idiom": "mac",
            "filename": "icon-512.png",
            "scale": "1x"
        },
        {
            "size": "512x512",
            "idiom": "mac",
            "filename": "[email protected]",
            "scale": "2x"
        }
    ],
    "info": {
        "version": 1,
        "author": "icon.wuruihong.com"
    }
}