AppIcon切图shell脚本工具

① 原文链接

#!/bin/sh

filename="icon.png"

dirname="image"

filename_array=("Icon-1.png" "Icon-60.png" "[email protected]" "Icon-72.png" "[email protected]" "Icon-76.png" "[email protected]" "Icon-ad32.png" "Icon-ad48.png" "Icon-ad96.png" "Icon-ad144.png" "Icon-Small.png" "Icon-Spotlight-iOS7.png" "[email protected]" "Icon-Spotlight.png" "[email protected]" "Icon.png" "[email protected]")

size_array=("58" "60" "120" "72" "144" "76" "152" "32" "48" "96" "144" "29" "40" "80" "50" "100" "57" "114")

mkdir $dirname

for ((i=0;i<${#size_array[@]};++i)); do

mkdir $dirname

m_dir=$dirname/${filename_array[i]}

cp $filename $m_dir

sips -Z ${size_array[i]} $m_dir

done

使用注意:
需要裁剪的icon图片,建议使用512x512 或者 1024x1024 的,命名为icon.png,且与脚本处在同一目录下;filename_array与size_array是一一对应的,需要什么名字什么尺寸的图标改整两个就行了!


② 原文链接

#! /bin/bash
# prepare
ROOT_DIR=$(pwd)

#check file exist
SOURCE_FILE="${ROOT_DIR}/1024.png"
echo $SOURCE_FILE
if [[ ! -e ${SOURCE_FILE} ]]; then
       echo "文件不存在"
       exit 1
fi
DEST_DIR="${ROOT_DIR}/icon"
#如果目录有图片先清空
if [[ -d ${DEST_DIR} ]]; then
       rm -rf dir ${DEST_DIR}
fi
mkdir -p "${DEST_DIR}"
Image_NAME=("29.png" "[email protected]" "40.png" "[email protected]" "87.png" "57.png" "[email protected]" "76.png" "[email protected]" "[email protected]" "[email protected]")
Image_SIZE=("29" "58" "40" "80" "87" "57" "114" "76" "152" "120" "180")

#sips starting
cp "${SOURCE_FILE}" "${DEST_DIR}"
for ((i=0; i<${#Image_SIZE[@]} ;i++)); do
        size=${Image_SIZE[i]}
        sips -Z ${size} "${SOURCE_FILE}" --out "${DEST_DIR}/${Image_NAME[i]}"
done

使用注意:
新建.sh结尾文件和一个1024.png的图,icon的基准的图片尺寸为1024*1024。

你可能感兴趣的:(AppIcon切图shell脚本工具)