📚 Encyclopedia

Tools & Workflow · updated 2026-11-16

Generating app assets with Python scripts (logos, GIFs, sounds)

pythonpillownumpyffmpeggifwebpwavassetsicons

Justin's rule is that app assets (icons, logos, sounds) are produced by a committed script so they can be rebuilt. The desktop has Pillow and numpy but no system ffmpeg, sox or OpenCV (a standalone ffmpeg lives at ~/bin/ffmpeg). Techniques that worked:

Keying a logo out of a white background

Deriving a dark variant of a light-background graphic

Un-multiply each pixel against white to recover color plus alpha (the inverse of compositing over white), composite onto the dark background (#121212), flip the lightness of black lettering, and keep opaque parts opaque via a hole-filled silhouette.

Video to GIF or frames

UI sounds without audio tools

Python's stdlib wave + math is enough for short UI sounds: a send "whoosh" as a 620 to 1250 Hz eased sweep over 130 ms, a receive "plink" as E5 to B5 over 170 ms, both around -12 dBFS with short fades. Commit the generator; regenerate to retune.

Preparing downloaded photos (Wikimedia Commons and similar)

A site that uses free-licensed photos needs a small, repeatable pipeline: a metadata file with one entry per photo (source page, author, license, license URL), the originals in a gitignored folder, and a script that produces the resized web versions. The metadata also feeds a credits page, which CC BY and CC BY-SA licenses require anyway. - Apply the EXIF orientation before resizing: img = ImageOps.exif_transpose(img). Pillow ignores the orientation tag on load, and most pipelines strip metadata on save, so a photo taken with the camera rotated comes out sideways or upside down with nothing left to tell the browser to fix it. - Download the original file, not a thumbnail URL at a chosen width. Commons thumbnail URLs now serve only a fixed set of widths; a request for 2400 px silently returned a 960 px image. Take the original url from the API or the file page and resize locally, then check the dimensions of what actually arrived. - Verify what a photo shows, not just its title. Files are named and categorized by uploaders. A set of pier photos labeled South Padre Island actually showed a pier on North Padre Island near Corpus Christi, more than 100 miles up the coast. For a site about a specific place, compare against a map or a second source before publishing. - Check the file page for a deletion or copyright notice before using it, and prefer versions without watermarks.

See also

Linked from

Sources: keyboard memory (history v1.17.0 to v1.19.1, post #1734), message memory (project_premium_wave), brittsdoggrooming memory (South Padre theme, post #1903)