← All Notes

Convert and Resize Images to WebP with ImageMagick

  • ImageMagick’s magick command to resize an image and convert it to WebP:
magick input.jpg -resize 1600 -strip -quality 80 output.webp
  • -resize keeps aspect ratio when only one value is provided

  • -strip removes metadata like EXIF/camera data. Which also helps reducing file size.

  • Batch convert JPG, JPEG, and PNG files in the current folder:

for file in *.{jpg,jpeg,png}; do [ -e "$file" ] && magick "$file" -resize 1600x1600 -strip -quality 80 "${file%.*}.webp"; done