Last active
June 19, 2024 09:31
-
-
Save spinsch/eefc37214e41d6f582fdf796f1247dac to your computer and use it in GitHub Desktop.
optimize images with mozjpeg recursively
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 | |
# | |
# usage: bash mozjpeg.sh directory | |
# | |
find "$1" -type f -name '*.jpg' -print0 | while read -d $'\0' file | |
do | |
echo ${file} | |
mkdir -p opt/"$(dirname "$file")" | |
djpeg $file | cjpeg -quality 80 | jpegtran -optimize -progressive > opt/$file | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment