Skip to content

Instantly share code, notes, and snippets.

@spinsch
Last active June 19, 2024 09:31
Show Gist options
  • Save spinsch/eefc37214e41d6f582fdf796f1247dac to your computer and use it in GitHub Desktop.
Save spinsch/eefc37214e41d6f582fdf796f1247dac to your computer and use it in GitHub Desktop.
optimize images with mozjpeg recursively
#!/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