config/scripts/resize_gif_zip.sh
2020-01-29 11:35:51 +01:00

24 lines
378 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
FILE_NAME=$1
input=$(mktemp -d)
function finish {
if [[ ! -z "$input" && -e $input ]]; then
echo "removing $input"
rm -rf "$input"
fi
}
trap finish EXIT
unzip "$FILE_NAME" -d "$input"
find "$input" -name "*.gif" -exec gifsicle --batch -i {} -O3 \;
cur=$(pwd)
cd "${input}"
zip -r "${cur}/$FILE_NAME" -- *
cd "${cur}"