Before you start

The exercise uses Oxipng 10.2.1 and the CLI manual from that tag. It keeps the originals and deliberately avoids options that alter hidden colors or strip metadata on request.

What you’ll make
An optimized transparent PNG and a report of its size, pixel hash, and retained color-related chunks.
What you’ll need
Oxipng 10.2.1, FFmpeg, ffprobe, Python 3 and a static 8-bit transparent PNG (or the fixture). Linux x86-64 provides the exact install example; other hosts use the matching official archive.

Step by step

  1. Stage a local tool

    From the official release, select the matching CPU/OS archive and verify its SHA-256 before extracting. The provided commands are for Linux x86-64 with glibc. Use project-local bin, not a system install.

  2. Create an output copy

    The fixture is a colored square with semi-transparent pixels. On an approved logo, preserve the original and use --out to name a new file. Avoid --alpha or strip options in the strict pixel test.

  3. Compare the decoded bytes

    Verify dimensions and SHA-256 of the same RGBA decode from each file. Smaller PNG bytes do not imply lower image quality. Reject a mismatch, even if both files seem identical on white.

  4. Check metadata and deployment needs

    The raw comparison does not prove ICC profiles or provenance survived. Compare hashes of color-related chunks and c2pa separately. Keep the original for contractual or provenance requirements; only deliver a smaller copy if it meets the brief.

Commands

set -e
mkdir -p bin download
name=oxipng-10.2.1-x86_64-unknown-linux-gnu.tar.gz
# Use this exact asset only on Linux x86-64 glibc.
curl --fail --location --proto '=https' --proto-redir '=https' -o "download/$name" "https://github.com/oxipng/oxipng/releases/download/v10.2.1/$name"
printf '%s  %s
' '46e3c4beb9aae57290ad809dd3374b07153579d3322a3778c53900633618b7c6' "download/$name" | sha256sum -c -
tar -xzf "download/$name" -C download
cp "$(find download -type f -name oxipng -print -quit)" bin/oxipng
bin/oxipng --version
# Use an authorized static PNG instead if you already have one.
ffmpeg -v error -n -f lavfi -i 'color=c=salmon@0.50:s=512x512,format=rgba' -frames:v 1 -compression_level 0 source.png
test ! -e optimized.png
bin/oxipng -o 2 --out optimized.png source.png
python3 - <<'EOF'
from pathlib import Path
from hashlib import sha256
from struct import unpack
from subprocess import check_output
def verify(f):
    b=Path(f).read_bytes()
    assert b.startswith(b"\x89PNG\r\n\x1a\n")
    i=8
    color={}
    while i+12<=len(b):
        n,k=unpack(">I4s",b[i:i+8]); payload=b[i+8:i+8+n]; i+=12+n
        if k==b'IHDR':
            size=unpack(">II",payload[:8])
            assert payload[8]<=8,'Use a static PNG at 8 bits per channel or below'
        assert k!=b'acTL','Animated PNG is outside this guide'
        if k in (b'iCCP',b'sRGB',b'gAMA',b'cHRM',b'cICP',b'c2pa',b'caBX'):
            color[k.decode()]=sha256(payload).hexdigest()
    raw=check_output(['ffmpeg','-v','error','-i',f,'-frames:v','1','-f','rawvideo','-pix_fmt','rgba','-'])
    assert len(raw)==size[0]*size[1]*4
    return len(b),size,sha256(raw).hexdigest(),color
a,b=map(verify,('source.png','optimized.png'))
print('before:',a,'\nafter:',b)
assert a[1:]==b[1:],'Pixel, size or metadata mismatch; retain original'
EOF

Sign-in & permissions

No account, API key, or external upload. A public dependency download may be needed. Pause before a system install; do not work around a restriction.

No agent skill, plugin, or MCP connector required.

Prompt for your agent

Use with: Codex, Claude Code, or another agent with local terminal and file access. Commands use Bash or a compatible shell.

Copy the whole prompt into a supported agent. After any manual step, tell the same agent to continue from that step.

Use a clean project folder for this workflow: Compress transparent PNGs without changing decoded pixels. Supported setup: Codex, Claude Code, or another agent with local terminal and file access. Commands use Bash or a compatible shell.. Start from the original documentation: https://github.com/oxipng/oxipng/blob/v10.2.1/MANUAL.txt.

1. SET UP
Start in a new project folder and check the listed tools. Use the pinned package or official platform build, no global upgrades. Check each command against its official source and stop on missing permissions or capabilities.

Documented commands or code reference (respect the comments and replace placeholders before running individual commands):
set -e
mkdir -p bin download
name=oxipng-10.2.1-x86_64-unknown-linux-gnu.tar.gz
# Use this exact asset only on Linux x86-64 glibc.
curl --fail --location --proto '=https' --proto-redir '=https' -o "download/$name" "https://github.com/oxipng/oxipng/releases/download/v10.2.1/$name"
printf '%s  %s
' '46e3c4beb9aae57290ad809dd3374b07153579d3322a3778c53900633618b7c6' "download/$name" | sha256sum -c -
tar -xzf "download/$name" -C download
cp "$(find download -type f -name oxipng -print -quit)" bin/oxipng
bin/oxipng --version
# Use an authorized static PNG instead if you already have one.
ffmpeg -v error -n -f lavfi -i 'color=c=salmon@0.50:s=512x512,format=rgba' -frames:v 1 -compression_level 0 source.png
test ! -e optimized.png
bin/oxipng -o 2 --out optimized.png source.png
python3 - <<'EOF'
from pathlib import Path
from hashlib import sha256
from struct import unpack
from subprocess import check_output
def verify(f):
    b=Path(f).read_bytes()
    assert b.startswith(b"\x89PNG\r\n\x1a\n")
    i=8
    color={}
    while i+12<=len(b):
        n,k=unpack(">I4s",b[i:i+8]); payload=b[i+8:i+8+n]; i+=12+n
        if k==b'IHDR':
            size=unpack(">II",payload[:8])
            assert payload[8]<=8,'Use a static PNG at 8 bits per channel or below'
        assert k!=b'acTL','Animated PNG is outside this guide'
        if k in (b'iCCP',b'sRGB',b'gAMA',b'cHRM',b'cICP',b'c2pa',b'caBX'):
            color[k.decode()]=sha256(payload).hexdigest()
    raw=check_output(['ffmpeg','-v','error','-i',f,'-frames:v','1','-f','rawvideo','-pix_fmt','rgba','-'])
    assert len(raw)==size[0]*size[1]*4
    return len(b),size,sha256(raw).hexdigest(),color
a,b=map(verify,('source.png','optimized.png'))
print('before:',a,'\nafter:',b)
assert a[1:]==b[1:],'Pixel, size or metadata mismatch; retain original'
EOF

2. PAUSE FOR ME IF NEEDED
For a host install, sign-in, permission screen, or model download that needs my consent, stop and tell me the exact app, control and what will be authorized. Do not enter passwords, OTPs or secrets in chat. Resume after I confirm.

3. BUILD THE FIRST RESULT
Optimize my approved static PNG, or create the provided synthetic fixture. Keep the original untouched, document both sizes, and accept optimized.png only if it is smaller and checks match. If checks disagree, report the specific difference and keep source.png for delivery.

4. CHECK THE RESULT
Require equal dimensions, RGBA hashes and relevant metadata hashes. Use a visual check on dark and light backgrounds for a real asset. Give me the actual file paths and anything that still needs a manual action. Do not publish or make a purchase.

Sources