Skip to content

Instantly share code, notes, and snippets.

@blakek
Created April 24, 2025 14:35
Show Gist options
  • Save blakek/9fef6af5f89e45514244c42f8d1bf366 to your computer and use it in GitHub Desktop.
Save blakek/9fef6af5f89e45514244c42f8d1bf366 to your computer and use it in GitHub Desktop.
Turns a boring SDR image into a retina-melting HDR AVIF
#!/usr/bin/env bash
# This script turns a boring SDR image into a retina-melting HDR AVIF
# Requires: ffmpeg with libaom-av1, ImageMagick (optional), and possibly a life reevaluation
INPUT="$1"
OUTPUT="${2:-shine.avif}"
if [ -z "$INPUT" ]; then
echo "Usage: $0 input.jpg [output.avif]"
exit 1
fi
echo "✨ Cooking up some visual trauma..."
# Step 1: Use ffmpeg to tone-map image and encode as HDR AVIF
ffmpeg -y -i "$INPUT" \
-vf "eq=brightness=1.0:saturation=2.2:contrast=1.3,format=gbrp10le" \
-color_primaries bt2020 \
-colorspace bt2020nc \
-color_trc smpte2084 \
-pix_fmt yuv420p10le \
-c:v libaom-av1 \
-still-picture 1 \
-strict experimental \
"$OUTPUT"
echo "✅ File saved as $OUTPUT — now go blind your followers."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment