↑ ↓ select, Enter open, Esc close

Convert images to AVIF recursively

Caution: This command changes the system. Understand what it does before you run it.

Adjust the values, the command updates live
user@server
find /var/www/vhosts/example.com/httpdocs/wp-content/uploads -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' \) -exec sh -c 'for f; do [ -e "$f.avif" ] || avifenc -s 6 "$f" "$f.avif" >/dev/null; done' sh {} +

Creates a file bild.jpg.avif next to each JPEG and PNG and skips images that were already converted. AVIF often compresses even better than WebP, but encoding is considerably slower. A lower speed value gives slightly better compression at the cost of more CPU time.

Note: avifenc is part of the libavif-bin package. With many images the run can take a long time and put noticeable load on the server, so it is best started with nice.

Open question before approval: Paketname libavif-bin auf Debian 12 und Ubuntu 24.04 bestätigen. Die Option -q für die Qualität gibt es erst ab libavif 1.0 (Ubuntu 24.04), Debian 12 hat 0.11, daher hier nur -s (Geschwindigkeit 0 bis 10).

Also searched as

  • bulk convert jpg to avif linux
  • convert images to avif command line
  • generate avif images for website
  • avifenc recursive conversion

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.