Skip to content

Archive

WebP

1 articles
Linux 26 Sep 2026 5 min read

Batch Convert JPEG and PNG to WebP with Bash and cwebp

Two files named photo.jpg and photo.png in the same directory would both become photo.webp. A batch converter that notices the collision only after it starts encoding may leave one image unconverted or replace an earlier result. It is better to check the entire input list first. The Bash script here uses cwebp for encoding and keeps a separate output tree. Its default auto mode encodes JPEG with lossy WebP and PNG with lossless WebP. The source images stay in place; existing destination files are skipped.