Last active
March 10, 2020 07:06
-
-
Save ZeppLu/3eb7fa51a0281fb75fa022866d587893 to your computer and use it in GitHub Desktop.
Recursively compress JPEG/PNG, requires mozjpeg & imagemagick
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
export IFS=" | |
" | |
# You may want to add patterns like "*.bmp", "*.tiff", etc | |
for i in $(find . \( -iname "*.jpg" \ | |
-o -iname "*.jpeg" \ | |
-o -iname "*.png" \)); do | |
echo "Compressing $i" | |
convert "$i" pnm:- | cjpeg > "$i.comp" | |
mv "$i" "$i.trash" | |
mv "$i.comp" "$i" | |
done | |
# To remove trash: | |
#find . -name "*.trash" -delete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment