All posts
PNG to JPEG via CLI
Convert PNG to JPEG with ffmpeg and a quality setting.
Open online converterPackages to install
Install ffmpeg — one command re-encodes PNG to JPEG.
ffmpeg
sudo apt-get update
sudo apt-get install -y ffmpegHow to run the command
Pass the PNG to -i and set JPEG quality with -q:v: lower is better (2 is near-lossless, 5–8 is smaller).
ffmpeg -y -i photo.png -q:v 2 photo.jpgDockerfile 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 \
ffmpeg && \
rm -rf /var/lib/apt/lists/*
WORKDIR /work
docker build -t png-to-jpeg .
docker run --rm -v "$PWD:/work" -w /work png-to-jpeg \
ffmpeg -y -i photo.png -q:v 2 photo.jpgExample commands
Run these locally after installing the packages, or inside the container from the Dockerfile.
ffmpeg -y -i photo.png -q:v 2 photo.jpgffmpeg -y -i photo.png -q:v 5 photo.jpeg