Skip to content

Instantly share code, notes, and snippets.

@danielstgt
Last active April 8, 2025 13:56
Show Gist options
  • Save danielstgt/072ea0844ba7342dc7aaac49d4658af7 to your computer and use it in GitHub Desktop.
Save danielstgt/072ea0844ba7342dc7aaac49d4658af7 to your computer and use it in GitHub Desktop.
Convert JPG and PNG to AVIF
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