Images and videos
These entries are about programatically doing stuff with media files.

create_thumbnail: create smaller versions of images
I’ve made a new tool that allows me to reuse my thumbnailing code across all my projects.

dominant_colours, a CLI tool for finding dominant colours in an image
A new tool for playing with images.

Getting a tint colour from an image with Python and k‑means
I want to display text next to an image that looks visually similar to the image, so I need to extract a tint colour.
15 articles
When square pixels aren’t square
When you want to get the dimensions of a video file, you probably want the display aspect ratio. Using the dimensions of a stored frame may result in a stretched or squashed video.
Detecting AV1-encoded videos with Python
I wrote a Python test to find videos that are encoded with AV1, so I can convert them to a codec my iPhone can play.
Why can’t my iPhone play that video?
The answer involves the AV1 video codec, Apple’s chips, and several new web APIs I learnt along the way.
Creating a personal wrapper around yt-dlp
I’ve written a new script which calls yt-dlp with my preferred options, so I don’t have to copy my configuration across different projects.
Resizing images in Rust, now with EXIF orientation support
A new version of Rust’s image crate has support for EXIF orientation, which allows me to resize images without mangling their rotation.
Looking at images in a spreadsheet
The
IMAGEandHYPERLINKfunctions allow me to use a spreadsheet as a lightweight, collaborative space for dealing with images.My custom <picture> plugin for Jekyll
How I make images that load quickly and look good for readers, and which are easy for me to manage.
A bookmarklet to show which responsive image was chosen
Debugging my <picture> and <source> tags.
Beware of transparent backgrounds when using AVIF with ImageMagick 6
You probably want to use version 7.
A script to get Live Text from images
Using Apple’s built-in tools to get OCR text from an image, but without going through a GUI.
Creating animated GIFs from fruit and veg
Some Python code for turning MRI scans of fruit and veg into animated GIFs.
Programatically finding the original filename of a photo in the macOS Photos Library
If you’re looking at a UUID’d file in the PhotosLibrary package, how do you find its original filename?
Using qlmanage to create thumbnails on macOS
How you can invoke Quick Look on the command-line to generate high-quality thumbnails.
Adjusting the dominant colour of an image
Adjusting the hue to get different colour variants of the same image.
Converting Acorn images on the command-line
I wrote some AppleScript to help me do batch conversion of Acorn images into formats like PNG and JPEG.
10 notes
Ignore AI upscaled YouTube videos with yt-dlp
Filter for formats that don’t include
-sr(“super resolution”) in their format ID.Get the duration of a video file with
mediainfoUse
mediainfo --Inform='Video;%Duration%' [VIDEO_FILE].Create solid-colour image placeholders to show before an image loads
Get an image from a video with ffmpeg
Convert an animated GIF to an MP4 with ffmpeg
Removing letterboxing from a video screenshot with ImageMagick
Using
-trimwill remove the black portions and leave you the unletterboxed image.Why is Pillow rotating my image when I save it?
Images can have orientation specified in their EXIF metadata, which isn’t preserved when you open and save an image with Pillow.
My config for running youtube-dl
The flags and arguments I find useful when I’m using youtube-dl.
Use the IMAGE function to insert an image into a spreadsheet
Replace black/white parts of an image with ImageMagick