How to Convert WebP Images to PNG or JPEG in Linux Using dwebp

While Google’s WebP image format has become the de facto standard across modern websites due to its impressive compression ratios and lightweight payload, working with WebP files in local graphic editors, document processors, or legacy command-line toolchains can prove frustrating. When you need to decode WebP graphics back into widely supported raster formats such as PNG, JPEG, or TIFF on Linux, the official dwebp utility provides a blazing-fast, lossless conversion tool directly inside the terminal.

What is dwebp and Why Use It?

The dwebp command is part of the official webp package authored by the WebP development team at Google. Unlike heavy graphical suites or general-purpose multimedia packages like ImageMagick that recompress or interpret colour profiles dynamically, dwebp focuses exclusively on decoding WebP bitstreams. This guarantees maximum fidelity, exact pixel rendering, and rapid execution speeds when processing large batches of downloaded images.

Step 1: Install dwebp on Your Linux Distribution

The dwebp command is provided inside the webp software package across the repositories of all major Linux distributions:

On Ubuntu, Debian, and Linux Mint:

sudo apt update
sudo apt install webp

On Fedora and RHEL:

sudo dnf install libwebp-tools

On Arch Linux and Manjaro:

sudo pacman -S libwebp

To confirm that the decoder is installed and check its current version, run:

dwebp -version

Step 2: Basic Syntax and Options

The basic command syntax for dwebp follows a simple input and output structure:

dwebp input_file.webp [options] -o output_file

Key parameters include:

  • -o : Specifies the destination output filename.
  • -ppm, -pgm, -bmp, -tiff : Selects an alternative non-PNG container format.
  • -quiet : Suppresses terminal progress indicators, ideal for automated shell scripts.
  • -crop x_position y_position width height : Crops the decoded canvas during extraction.
  • -resize width height : Scales the output image dimensions simultaneously while decoding.

Step 3: Convert a WebP Image to PNG

By default, when you supply a .png file extension with the -o argument, dwebp decodes the image into uncompressed 24-bit RGB or 32-bit RGBA (preserving alpha channel transparency):

dwebp photograph.webp -o photograph.png

Because PNG supports lossless alpha transparency, all semi-transparent drop shadows and cutouts present in the original WebP graphic are retained completely intact.

Step 4: Convert a WebP Image to JPEG

If you require JPEG files for legacy publishing software or lightweight photo albums, dwebp directly outputs PAM, PPM, or PNG. You can pipe dwebp directly to standard utilities or combine it with cjpeg or ffmpeg for instantaneous JPEG compilation:

dwebp banner.webp -ppm -o - | cjpeg -quality 90 > banner.jpg

Alternatively, decode to a clean PNG first and convert via ImageMagick:

dwebp banner.webp -o banner.png && convert banner.png banner.jpg

Step 5: Batch Convert All WebP Files in a Directory

If your Downloads or media directory contains dozens of WebP screenshots or asset files, you can automate conversions with a straightforward Bash shell loop:

for file in *.webp; do
    [ -f "$file" ] || continue
    dwebp "$file" -o "${file%.webp}.png"
done

This script iterates through every .webp file in the current working directory, strips the trailing extension with Bash parameter expansion, and exports a matching .png file while preserving the original WebP assets.

Troubleshooting Common dwebp Errors

  • Animated WebP Files: If your WebP image is an animated sequence (similar to an animated GIF), dwebp will only decode the first frame of the animation. To extract all frames from an animated WebP file, use the companion tool anim_dump (provided in the same webp package):
    anim_dump animation.webp
  • Bitstream Version Error: If decoding fails with a message indicating an unsupported bitstream, your distribution’s libwebp package may be outdated. Update your operating system packages to ensure support for modern lossy WebP compression revisions.
  • Loss of Transparency: If you convert from WebP to JPEG, transparency will be rendered as a solid background colour because the JPEG specification does not support alpha channels. Always use PNG if the image features transparent elements.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.