pngdefy可以将Xcode中pngcrush处理过的png图片进行还原
ImageMagick可以通过命令对图片进行处理
具体见
GitHub
#输入主图片,如AppIcon.png(1024*1024)
BASEIMAGE=$1{
#获取文件名称,去除后缀
FILENAME=${BASEIMAGE%.*}
function generateIcon () {
#拷贝图片后,重新命名,pngdefry进行解析, 并转化为指定的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"}