How to Batch Convert Images to WebP

event

Published

event_available

Updated 4/25/2024

Convert images to WebP quickly and easily on Mac using this command line tutorial. Get Homebrew and WebP installed.

batch convert images to webp cover - a bunch of abstract stuff on a computer, illustration

Converting a folder of images to WebP format can be accomplished using various methods depending on your operating system and the tools you are comfortable using.

This tutorial covers converting images on a Mac using the command line (Terminal). It’s a technical solution that might seem intimidating, but it’s actually quite easy.

Requirements

Before we go through the process, you’ll need to have two things installed and ready.

Homebrew

Homebrew is a package manager that makes it easy to install software via the command line.

To install, open Terminal and run this command:

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

This code should automatically download and install the software. Consider checking the official website to ensure this code is current.

WebP Converter

This tool will allow us to convert our images to WebP. To install it, run this in Terminal:

brew install webp

This command uses Homebrew to download and configure the package.


Once you have both installed, you can repeat this process without worrying about this part.

Convert Images to WebP

Follow these steps to optimize your images for the web.

1. Open your image folder in Terminal

You can do this several ways, but here’s one of the quickest:

  1. Navigate to the folder in Finder. (Way easier than the command line.)
  2. Right-click on the folder and choose Services > New Terminal at Folder.
New Terminal at Folder

This should open a new Terminal window, preparing you for the next step.

2. Run a conversion script

Now you can simply copy/paste one of these options into Terminal and hit Enter.

The right code will depend on the image types you’re trying to convert. You can run each command if needed, to cover all your image types.

For PNGs

for i in *.png; do cwebp "$i" -o "${i%.png}.webp"; done

For JPGs

for i in *.jpg; do cwebp "$i" -o "${i%.jpg}.webp"; done

For GIFs

for i in *.jpg; do cwebp "$i" -o "${i%.jpg}.webp"; done

That’s it! Terminal should print out a bunch of technical mumbo jumbo, and your folder should have WebP copies of the images.

You can also create a script (easily using ChatGPT) to convert any type of image, but the process requires a bit more personalization and technical adoption.

Using Online Tools

Many online tools allow you to convert images from PNG to WebP. You can upload your folder or images and convert them directly in the browser. Here’s how:

  1. Search for an Online Converter: Find a service by searching for “online PNG to WebP converter”.
  2. Upload and Convert: Follow the website’s instructions to upload your PNGs and convert them to WebP.

Be sure to vet the website and ensure it’s nothing spammy. CloudConvert should be a good solution for most people, but it has limits, so try the command line method if you reach yours.

Bottom Line

While there are many other ways to convert multiple images to WebP, the command line is one of the easiest and most effective methods. Enjoy your optimized files and faster loading times!

Topics

Get Powerful Templates

Streamline your content management
with our dynamic Notion templates.