Created
May 4, 2020 15:28
-
-
Save theonelucas/dcd80a082abd569a7b64c5f14824a545 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 | |
images=() | |
# Get all non JPG images | |
readarray -d '' images < <(find ./ -type f \( -iname \*.jpeg -o -iname \*.png \) -print0) | |
# Convert them to JPG | |
for i in "${!images[@]}" | |
do | |
image_path=${images[i]} | |
image_name="${image_path%.*}" | |
convert "$image_path" -verbose -quality 100% "${image_name}.jpg" | |
rm "$image_path" | |
done | |
# Optimize all images | |
find -type f -name "*.jpg" -exec jpegoptim -ps --strip-all {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment