我在 Mac M1 上使用 Automator 批量/批量压缩图像。该脚本在我的旧 Mac 上运行良好。他们怎么不再工作了?
JPEGOptim 已安装。Automator 说工作流程已经完成,但实际文件没有变化
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
BIN_PATH=~/Library/Services/.bin
for f in "$@"; do
if [ -d $f ]; then
echo "TODO: nothing to compress now!"
elif [[ $f == *.png ]]; then
if hash optipng 2>/dev/null; then
optipng -o7 "$f"
else
$BIN_PATH/optipng -o7 "$f"
fi
if hash pngcrush 2>/dev/null; then
pngcrush -brute -reduce -ow "$f"
else
$BIN_PATH/pngcrush -brute -reduce -ow "$f"
fi
elif [[ $f == *.jpg ]]; then
if hash jpegoptim 2>/dev/null; then
jpegoptim "$f" --strip-all --force --all-progressive --size=150k
else
echo "No jpegoptim installed, skipped."
fi
elif [[ $f == *.svg ]]; then
if hash svgo 2>/dev/null; then
svgo "$f"
else
echo "No SVGO installed, skipped."
fi
else
echo "TODO: nothing to compress now!"
fi
done;