xcode_proj_dir="${WORKSPACE}/iQIYIVR/iQIYIVR-GoogleiOSVR"
ios_bash_tool_dir="${WORKSPACE}/tool/iOS"
cp -rf "${ios_bash_tool_dir}/unity_ios_support/554/AppIcon.appiconset" "${xcode_proj_dir}/Unity-iPhone/Images.xcassets/"
# iOS端插入到“xcodebuild”執(zhí)行之前
# 判斷腳本運行環(huán)境是否安裝了ImageMagick
convertPath=`which convert`
if [[ ! -f ${convertPath} || -z ${convertPath} ]]; then
echo "==============
Error: 你需要先安裝 ImageMagick!!!!:
brew install imagemagick
=============="
exit 0
fi
# 基于上下文編寫要顯示在icon上的信息吊宋,支持\n換行
CURRENT_TIME=$(date +"%Y%m%d%H%M")
caption="$CURRENT_TIME\n${jenkins_param_bundleVersion} \n${BUILD_NUMBER}"
echo "caption: ${caption}"
# 處理圖片步驟
function generateIcon() {
originalImg=$1
# 添加散射+高斯模糊
convert ${originalImg} -spread 10 spread-original.png
convert spread-original.png -blur 10x8 blur-original.png
# 截取下部分
width=`identify -format %w ${originalImg}`
height=`identify -format %h ${originalImg}`
height_0=`expr ${height} / 2`
height_1=$((${height} - ${height_0}))
convert blur-original.png -crop ${width}x${height_0}+0+${height_1} crop-blur-original.png
# 加字
point_size=$(((8 * $width) / 58))
convert -background none -fill black -pointsize ${point_size} -gravity center caption:"${caption}" crop-blur-original.png +swap -composite label.png
# 合成
composite -geometry +0+${height_0} label.png ${originalImg} ${originalImg}
# 清除文件
rm blur-original.png
rm crop-blur-original.png
rm label.png
rm spread-original.png
}
if [ $jenkins_param_app_icon != "release" ]; then
# 找到appicon的文件夾,遍歷執(zhí)行icon修改
for file in ${iconpath}/*
do
if [[ "${file##*.}"x = "png"x ]]
then
echo "filename: ${file}"
generateIcon $file
fi
done
fi
# ========= end for =========
指定文件可以使用下面的方式
generateIcon "${iconpath}/Icon-120.png"