Opening files one by one in a GUI is fine for a handful of images. When you have 200 product photos that need converting to WebP, or an archive of TIFFs that need JPEG versions, clicking is a trap. ImageMagick’s magick mogrify turns a folder’s worth of work into a single line:

magick mogrify -format webp -quality 82 -path ./output *.jpg

The -path flag is non-negotiable. Without it, mogrify overwrites your originals in place. Always write to a separate output folder and keep sources intact.

Need to resize at the same time? Chain the options — the \> modifier means "only shrink, never enlarge", a sensible default for web images:

magick mogrify -format webp -quality 82 -resize 1600x1600\> -path ./output *.jpg

For PNG-to-AVIF, swap -format avif and drop quality to 60–70 — AVIF’s encoder is more aggressive, so the same number produces a smaller file. It’s also slower, so budget the time or parallelise with xargs or GNU parallel.

01The gotchas that bite

GotchaWhat to do
Colour profilesConvert to -colorspace sRGB before -strip, or colours shift when the browser assumes sRGB.
Naming collisionsphoto.tiff and photo.jpg both become photo.webp — one silently overwrites the other. Segregate inputs.
Metadata (EXIF)Add -strip to save bytes and avoid leaking GPS location.
Verify firstRun on ten images, check sizes and colours, then point it at the full archive.
82WebP quality for a good size balance
60–70AVIF quality (more aggressive encoder)
1600pxexample max web dimension