Advertisement

How to Convert WebP to PNG in Linux

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

GIMP Error Message Webp

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.

  1. Open your favorite terminal app.
  2. Type the following command:
    dwebp file.webp -o file.png
  3. The output file will be file.png in the PNG format.Linux Webp To Png

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:

  1. Open your favorite terminal app.
  2. Type the following command:
    ffmpeg -i file.webp file.png

Linux Webp To Png FfmpegKeep 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

Author: Sergey Tkachenko

Sergey Tkachenko is a software developer who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

7 thoughts on “How to Convert WebP to PNG in Linux”

    1. ———–
      1. Create a *.sh file:

      #!/bin/bash
      for a in ./*.webp; do
        old=$IFS
        IFS="\n"
        ffmpeg -i "$a" "${a[@]/%webp/png}"
        IFS=$old
      done

      ————
      2. Then make it executable: chmod +x yourfile.sh
      ———–
      3. Run it in the directory with your files.

Leave a Reply

Your email address will not be published.

css.php
Using Telegram? Subscribe to the blog channel!
Hello. Add your message here.