How to batch convert images to WebP with Imagemagick on MacOS

1 Install homebrew by opening up your terminal application and copying and pasting the following line of code in it. Then hit enter.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/.sh)"

2. Run the following command in your terminal application:

brew install imagemagick

3. Create an empty folder on your mac.

mkdir ~/Pictures/WebP

4. Navigate to the folder of png or jpg images you want to convert to WebP in your terminal.

cd ~/YourImages/

5. Issue the following command replacing “.png” with the file extension of the files you need converted (the source files).

magick mogrify -format webP -path ~/Pictures/WebP/ *.png

6. To change the quality of your images using lossless compression, you can use the “-quality” and “-define” arguements like so…

magick mogrify -format webP -quality 80 -define webp:lossless=true -path ~/Pictures/WebP/ *.png

where -quality 80 is to reduce the quality of your images by 20% (only 80% of the original quality is used).

7. To use lossy compresssion with reduced quality you can use the “-define webp:lossless=false” arguement like so…

magick mogrify -format webP -quality 60 -define webp:lossless=false -path ~/Pictures/WebP/ *.png

This will reduce your image quality to 60% of the original image, but shrink the filesize of your photos tremendously. This will also make your original image quality unrecoverable since it is lossy. So don’t delete your original photos unless you are absolutely sure you don’t need them scaled up to a larger size and better quality. For website use, it is recommended that you scale down your image quality anywhere from 60%-80%, to decrease page load times and image load times. However, if you already are using small images this may not be neccessary, and your image compression and filesize (lossy or lossless) is relatively subjective depending upon what you are trying to accomplish with your website. If you desire High quality UHD or 4K photos all the time with slower load times, then stick with lossless with less compression. If you desire faster load times with lesser quality images, the oposite extreme end is to use lossy compression with more compression, which should shrink your files pretty well and prep them for quick load times on a website.

7. Wait for the images to be converted. Your newly converted images can be found in your ~/Pictures/WebP folder after its complete.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.