您好,登錄后才能下訂單哦!
目的很簡單,就是從ipa包中抽取圖片資源,然后按照ipa中的目錄結構存放.
#!/bin/sh
#usage:extra-p_w_picpath-from-ipa <ipa-file>|<Payload-dir> <target-dir>
echo $#
if [[ $# != 2 ]]; then
echo "extra-p_w_picpath-from-ipa <ipa-file>|<Payload-dir> <target-dir>"
exit 1
fi
IPA_FILE=$1
TARGET_DIR=$2
if [[ -f "$IPA_FILE" ]]; then
echo "解壓ipa包到臨時目錄"
IPA_DIR="/tmp/extra-p_w_picpath-from-ipa/temp/`date "+%Y%m%d-%H%M%S"`"
echo "temp-dir: " $IPA_DIR
#rm -rf $IPA_DIR
mkdir -p $IPA_DIR
echo "unzip $IPA_FILE begin ..."
unzip -q "$IPA_FILE" -d "$IPA_DIR"
if [[ $? != 0 ]]; then
echo "unzip $IPA_FILE failed"
exit 2
else
echo "unzip $IPA_FILE successed"
fi
# 定位到*.app目錄
IPA_DIR="$IPA_DIR/""Payload/""`ls "$IPA_DIR/"Payload`"
else
IPA_DIR=$IPA_FILE
fi
copy_p_w_picpath()
{
#echo "begin copy p_w_picpath"
R="$1"
D="$2"
S="$3"
#echo "建立和ipa包相同層次的目錄機構"
T=${S/$R/$D}
mkdir -p `dirname $T`
cp -rf $S $T
if [[ $T =~ \.png$ ]]; then
#echo "利用PNGCrush還原被優化的png圖片"
mv $T $T.orign
xcrun -sdk iphoneos pngcrush -revert-iphone-optimizations -q $T.orign $T
if [[ $? != 0 ]]; then
echo "revert failed: " $T.orgin
else
rm $T.orign
fi
fi
#echo "end copy p_w_picpath"
}
# 導出函數 供下面的find方法使用
export -f copy_p_w_picpath
echo "copy jpg p_w_picpath"
find "$IPA_DIR" -name "*.jpg" -exec sh -c "copy_p_w_picpath $IPA_DIR $TARGET_DIR {}" \;
echo "process png p_w_picpath"
find "$IPA_DIR" -name "*.png" -exec sh -c "copy_p_w_picpath $IPA_DIR $TARGET_DIR {}" \;
echo "finished"
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。