Convert and Resize Images to WebP with ImageMagick
- ImageMagick’s
magickcommand to resize an image and convert it to WebP:
magick input.jpg -resize 1600 -strip -quality 80 output.webp
-
-resizekeeps aspect ratio when only one value is provided -
-stripremoves 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