All posts

JPEG to PNG via CLI

Re-encode JPEG as PNG with ffmpeg.

Open online converter

Packages to install

The ffmpeg package is enough — it reads JPEG and writes PNG.

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

How to run the command

Pass the input JPEG with -i and the output PNG filename. -y overwrites the output without asking.

ffmpeg
ffmpeg -y -i photo.jpg 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 \
        ffmpeg && \
    rm -rf /var/lib/apt/lists/*

WORKDIR /work
docker build && docker run
docker build -t jpeg-to-png .
docker run --rm -v "$PWD:/work" -w /work jpeg-to-png \
  ffmpeg -y -i photo.jpg photo.png

Example commands

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

Example 1
ffmpeg -y -i photo.jpg photo.png
Example 2
ffmpeg -y -i photo.jpeg -update 1 photo.png