Files
assistant-android/scripts/compress_resources.sh

51 lines
1.3 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# *****************************************************************************
# @author CsHeng
# @2016.2.17 初始pngquant版本
# @2016.3.8 增加对音频的处理
#
# 使用pngquant对图片素材进行压缩压缩后gradle脚本copyResource会将../res目录copy到目的地
# 使用lame处理mp3
# 由于pngquant/lame是需要系统额外安装的故不将此命令写入gradle脚本
# Sample: brew install ImageMagick lame
#
# 选项:
# -s src dir of images, default ../res
#
# *****************************************************************************
CWD=$(cd "$(dirname "$0")"; pwd)
INPUT="${CWD}/../res"
while getopts "i:0:" arg
do
case ${arg} in
s)
INPUT=${OPTARG}
;;
?)
echo "unknown argument"
exit 1;
;;
esac
done
#find ${INPUT} -name '*.png' -exec bash -c 'echo $0 -f -o $0 & pngquant $0 -f -o $0' {} \;
# compress pngs to 8bit color, keep alpha channel
images=$(find ${INPUT} -name '*.png')
for f in ${images}
do
echo pngquant ${f} -f -o ${f}
pngquant ${f} -f -o ${f}
done
# convert mp3 to 64bit/44100KHz, normal is 96-128bit/44100KHz, --resample 22050 don't help
mp3s=$(find ${INPUT} -name '*.mp3')
for f in ${mp3s}
do
echo "mv ${f} ${f}.bak & lame --mp3input -b 64 ${f}.bak ${f} & rm ${f}.bak"
mv ${f} ${f}.bak
lame --mp3input -b 64 ${f}.bak ${f}
rm ${f}.bak
done