Last active
April 8, 2025 13:56
-
-
Save danielstgt/072ea0844ba7342dc7aaac49d4658af7 to your computer and use it in GitHub Desktop.
Convert JPG and PNG to AVIF
This file contains hidden or 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
setopt extended_glob | |
for img in *.(#i)(jpg|jpeg|png) | |
do | |
if [ -f "$img" ]; then | |
name="${img%.*}" | |
if magick "$img" -strip -quality 60 -define heic:avif-speed=0 -define heic:subsample=420 "${name}.avif" | |
then | |
echo "🌇 Converted: $img -> ${name}.avif" | |
rm "$img" | |
echo "🚾 Deleted: $img" | |
else | |
echo "❌ Error converting: $img" | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment