All posts

WebP to JPEG via CLI

Two steps: dwebp decodes WebP to PNG, ffmpeg encodes JPEG.

Open online converter

Packages to install

You need webp (dwebp) and ffmpeg. JPEG has no alpha, so transparency becomes a solid background.

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

How to run the command

First dwebp photo.webp -o photo.png, then ffmpeg -y -i photo.png -q:v 2 photo.jpg. Chain them with && if you want.

dwebp + ffmpeg
dwebp photo.webp -o photo.png
ffmpeg -y -i photo.png -q:v 2 photo.jpg

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 \
        ffmpeg && \
    rm -rf /var/lib/apt/lists/*

WORKDIR /work
docker build && docker run
docker build -t webp-to-jpeg .
docker run --rm -v "$PWD:/work" -w /work webp-to-jpeg \
  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
ffmpeg -y -i photo.png -q:v 2 photo.jpg
Example 2
dwebp photo.webp -o /tmp/photo.png && ffmpeg -y -i /tmp/photo.png photo.jpeg