Convert directory of images on the command line
I had a need, well I always have a need but I finally got around to figuring this out, to resize a directory of images. I finally broke up with Adobe and had historically used the Photoshop batch functionality which was always wonky at best so that’s no longer possible. I’ve done some digging and discovered yet again that Linux just does everything better. So without further adieu the command:
$ mogrify -path ./webp_images/ -format webp -quality 80 -resize 1200x1200\> *.jpg
Everything here is straightforward aside from the ‘\>’ after the resize flag. This extra bit prevents smaller images from being upscaled. FYI, you’ll need imagemagick installed to run the mogrify command.
Extra credit, here’s a command to mogrify a directory of images no matter the file type:
for img in *.{jpg,jpeg,png,bmp}; do [ -e "$img" ] && mogrify -path ./webp_images/ -format webp -quality 80 -resize 1200x1200\> "$img" donePublished on August 5, 2025