Last active
February 2, 2020 04:24
-
-
Save iitenkida7/23a3496827cbba07b42b69821f1830d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -eu | |
# mozjpeg 使って指定ディレクトリのjpeg ファイルを再帰的に 圧縮 | |
# https://github.com/mozilla/mozjpeg | |
if [ ! -d $1 ] ;then | |
echo "該当ディレクトリが見当たりません" 1>&2 | |
exit 1 | |
fi | |
for IMAGE in $(find $1 -type f -name "*.jpg" -o -name "*.jpeg") ; do | |
echo -n "$(ls -lh "${IMAGE}" | awk '{print $9, "["$5}' ) => " | |
/opt/mozjpeg/bin/cjpeg -optimize -quality 70 "${IMAGE}" > "${IMAGE}_renew" | |
mv -f "${IMAGE}_renew" "${IMAGE}" | |
ls -lh "${IMAGE}" | awk '{print $5"]"}' | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment