WebP is a modern image format created by Google. It was made specially for the Web, providing a high compression ratio without affecting the image quality. On Windows, any image viewer like IrfanView can open WebP images and save them as JPG/PNG. On Linux however, it might be hard to edit or convert a WebP image, because traditional image editing tools like GIMP do not support WebP yet. Here is how to convert a WebP image to the PNG format and vice versa.
Advertisеment
There are two methods you can use to get a PNG image from an existing WebP image. You can use either libwebp or ffmpeg packages which provide tools for our tasks.
Convert WebP to PNG
Depending on your distro, libwebp may be installed out-of-the-box, or not. For example, in Arch Linux package dependencies are not strict, so libwebp doesn't get installed when you install the GUI. You should install it manually by running the command as root:
# pacman -S libwebp
On a Debian-based distro like Linux Mint, issue the command:
# apt install webp
The package provides the following tools:
- cwebp - a WebP encoder tool.
- dwebp - a WebP decoder tool.
- vwebp - a WebP viewer app.
- wepmux - a WebP muxing tool.
- gif2webp - a tool for converting GIF images to WebP.
To convert a WebP image to PNG in Linux, do the following.
- Open your favorite terminal app.
- Type the following command:
dwebp file.webp -o file.png
- The output file will be file.png in the PNG format.
Note: Unfortunately, dwebp only converts WebP to PNG, but not to JPG. So, if you need to get a JPEG image from your WebP file, you need to convert it to PNG first, and then convert the PNG image to JPG using a tool like GIMP or convert it using ImageMagicK.
Convert WebP to PNG with ffmpeg
If you can't get libwebp installed, you can go with ffmpeg. Unlike libwebp, ffmpeg is widely used and comes preinstalled in many distros. Do it as follows:
- Open your favorite terminal app.
- Type the following command:
ffmpeg -i file.webp file.png
Keep in mind that ffmpeg produces bigger files than the WebP encoder. You might need to adjust its options and optimize the output file.
Convert PNG files to WebP
The opposite conversion might also be useful. In a number of situations, WebP provides a better compression ratio than PNG. To convert a PNG file to WebP, execute the following command:
cwebp file.png -o file.webp
The default quality for WebP is set to 75. You can increase or reduce it by specifying the -q argument for the encoder, as follows.
cwebp -q 80 file.png -o file.webp
That's it.
Support us
Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:
If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!
Advertisеment
Thanks for sharing! I will try in Linux when I get a chance
You are most welcome.
I’ve installed the webp package on Ubuntu and it works great.
Thanks for these instructions!
How to convert a few files?
———–
1. Create a *.sh file:
————
2. Then make it executable: chmod +x yourfile.sh
———–
3. Run it in the directory with your files.
gThumb can open/convert it to PNG or JPEG
Thanks!