Easily Convert Images to WebP on Linux and macOS

Learn how easy it is to convert images to WebP on Linux and macOS. Converting WebP to PNG is just as easy. The same with GIFs

WebP is a modern, open source, image format that provides superior lossless and lossy compression ( as well as animation and alpha transparency ) for images on the web.

There are a lot of online tools that will allow you to convert your images but, why upload your images on a random server when you can easily convert them right on your computer?

Installing libwebp on Linux

You’ll find the necessary tools in your Linux’s distro default repositories. However, depending on the distro you’re running, libwebp is available under different names:

  • Arch and derivates: sudo pacman -S libwebp
  • Ubuntu and derivates: sudo apt install webp
  • Fedora: sudo dnf install libwebp-tools

 

Installing libwebp on macOS

To install the necessary tools on macOS, you first need to have Homebrew installed.

Once Homebrew is up and running, you can install libwebp by running brew install webp.

 

Converting images to WebP

The conversion process is identical on both Linux and macOS. Once you have libwebp installed on your OS, open up the terminal and:

1. cd into path ( where the image you want to convert is located )
2. run cwebp original.jpg -o converted.webp ( replace original and converted with the appropiate names. for the converted pic, you can use whatever name you please )
2.1 you can use the -q option to control the quality level. Generally, a level of 80-85 will give you good results. The command will be: cwebp original.jpg -q 80 -o converted.webp

For the purposes of this article, I’ve used a 6K, 21MB photo. This is the result:

There’s a lot more flags that you can use. To see all the flags and options of libwebp, run cwebp --help

 

Converting Gif to WebP

By now, you might’ve tried to convert a .gif into .webp, which resulted in an error along the lines of “Error! Could not process file pic.gif”.

To convert a .gif file to .webp, run gif2webp original.gif -o gif.webp.

 

Converting WebP to PNG

To convert any .webp file into a .png file you can run dwebp original.webp -o image.png

To learn more about WebP, you can check out this page.



SUPPORT FSM

Monero (XMR) 43GnqUNJrTi9QyL7kEH8vM8pgWGCE6bjv1FSRipeNMM4TTeNnUVsRBb6MfMpQYxtLE7ReonxVVSXz2rFCEdW5H11LC3x73b
Bitcoin (BTC) 3PvaJPytg4pApTP5yCGpr62pRtudMgyfMQ
Ethereum (ETH) 0xd3c8677A4CfD9e8b4dFBb7720be2adb490Bd36b2