All posts

WebP to PNG via CLI

Decode WebP to PNG with dwebp, keeping transparency.

Open online converter

Packages to install

The webp package includes dwebp, which decodes WebP to PNG and other rasters.

webp
apt install
sudo apt-get update
sudo apt-get install -y webp

How to run the command

dwebp reads the WebP and writes PNG to the -o file. This is the inverse of cwebp.

dwebp
dwebp photo.webp -o photo.png

Dockerfile example

Build a minimal Ubuntu image with the required packages and run the conversion inside the container.

Dockerfile
FROM ubuntu:24.04

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        webp && \
    rm -rf /var/lib/apt/lists/*

WORKDIR /work
docker build && docker run
docker build -t webp-to-png .
docker run --rm -v "$PWD:/work" -w /work webp-to-png \
  dwebp photo.webp -o photo.png

Example commands

Run these locally after installing the packages, or inside the container from the Dockerfile.

Example 1
dwebp photo.webp -o photo.png
Example 2
dwebp -nofancy photo.webp -o photo.png