pngdefy可以將Xcode中pngcrush處理過的png圖片進行還原
ImageMagick可以通過命令對圖片進行處理
具體見
GitHub
#輸入主圖片,如AppIcon.png(1024*1024)
BASEIMAGE=$1{
#獲取文件名稱贤徒,去除后綴
FILENAME=${BASEIMAGE%.*}
function generateIcon () {
#拷貝圖片后跪腹,重新命名,pngdefry進行解析, 并轉(zhuǎn)化為指定的3x
fileName=${FILENAME}$1x$1@3x.png
cp ${BASEIMAGE} ${fileName}
./pngdefry -o ./ ${fileName}
#計算尺寸
size=`expr 3 \* $1`
convert ${fileName} -resize ${size}x${size} ${fileName}
convert betaRibbon.png -resize ${size}x${size} resizedBetaRibbon.png
composite resizedBetaRibbon.png ${fileName} ${fileName}
#2x
fileName=${FILENAME}$1x$1@2x.png
cp ${BASEIMAGE} ${fileName}
./pngdefry -o ./ ${fileName}
size=`expr 2 \* $1`
convert ${fileName} -resize ${size}x${size} ${fileName}
convert betaRibbon.png -resize ${size}x${size} resizedBetaRibbon.png
composite resizedBetaRibbon.png ${fileName} ${fileName}
}
echo "##generateIcon 60x60"generateIcon "60"
echo "##generateIcon 29x29"generateIcon "29"
echo "##generateIcon 40x40"generateIcon "40"
echo "##generateIcon 57x57"generateIcon "57"}