Menu

Hack: Make PDFs Amber-on-Black

Recently, I wanted to read a scanned PDF on my Kobo. The white-on-black PDF was quite “bright” for my tastes as I usually read at night. The Kobo supports dark mode for epubs but it doesn’t seem to have a means of inverting the colour of PDFs natively. Moreover, I like to read things as amber-on-black. A bit of vibe-coding and fiddling around yielded the following terrible script to make a PDF “amber on black.”

#!/usr/bin/env bash

set -e

if [ $# -ne 2 ]; then
    echo "Usage: $0 input.pdf output.pdf"
    exit 1
fi

INPUT="$1"
OUTPUT="$2"
TMPDIR="$(mktemp -d)"

echo "Converting PDF pages to images..."
DPI=300

gs \
  -dSAFER \
  -dBATCH \
  -dNOPAUSE \
  -sDEVICE=png16m \
  -r$DPI \
  -sOutputFile="$TMPDIR/page-%04d.png" \
  "$INPUT"

COLORIZE="0,30,100" # yellow on black

echo "Processing pages (invert + amber)..."
for img in "$TMPDIR"/page-*.png; do
    echo "Processing: $img -> $img.pdf";
    convert "$img" \
        -colorspace Gray \
        -negate \
        -colorize $COLORIZE \
        "$img.pdf"
done

echo "Reassembling PDF..."
pdftk "$TMPDIR"/page-*.pdf cat output "$OUTPUT"

Echo "Cleaning up..."
rm -rf $TMPDIR"

echo "Done: $OUTPUT"

Published: Jan 23, 2026 @ 21:57.

Tags:

#hack #reading

Backlinks:

Navigation Menu

Home / Now / Blog / Notes / Reading / Office Camera / Tags / Bookmarks / RSS Feeds / Top of Page

Thanks for reading! If you have any comments or questions about the content, please let me know. Anyone can contact me by email.