All posts
JPEG to WebP via CLI
Encode JPEG as WebP with cwebp at quality 90.
Open online converterPackages to install
The webp package installs cwebp for encoding and dwebp for decoding.
webp
sudo apt-get update
sudo apt-get install -y webpHow to run the command
cwebp -q 90 reads a JPEG and writes WebP to the -o path. Quality 90 is a solid size/quality trade-off.
cwebp -q 90 photo.jpg -o photo.webpDockerfile example
Build a minimal Ubuntu image with the required packages and run the conversion inside the container.
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 -t jpeg-to-webp .
docker run --rm -v "$PWD:/work" -w /work jpeg-to-webp \
cwebp -q 90 photo.jpg -o photo.webpExample commands
Run these locally after installing the packages, or inside the container from the Dockerfile.
cwebp -q 90 photo.jpg -o photo.webpcwebp -q 80 photo.jpeg -o photo.webp