Media Optimization
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. See the section bibliography for the reference material consulted while preparing these pages. |
Users upload photos and videos in whatever format their device produced, and a platform has to serve each client a file it can decode, at a size it needs, with as few bytes as possible. This sub-section describes how the backend does that: turn every image into a set of formats and sizes (with a BlurHash placeholder), turn every video into a ladder of renditions that stream adaptively, produce covers and thumbnails, and do all of it in background workers rather than in the HTTP request. It is current as of 2026-10-07. Each page states the versions it was checked against and flags unmaintained or restrictively licensed libraries.
Pages
| Page | What it covers |
|---|---|
JPEG, PNG, WebP, AVIF, JPEG XL and HEIC compared. Quality settings, EXIF orientation, colour profiles, and the libvips, cwebp and avifenc commands. |
|
Width breakpoints, fit and crop modes, storage keys, eager versus on-the-fly generation, cache headers, and what the API must return for srcset and picture. |
|
The equations, the string layout, decoding and punch, a worked example, ThumbHash, and the implementations per language. |
|
Codecs, containers, rate control, GOP, audio, FFmpeg commands, and the bitrate ladder from the Apple HLS Authoring Specification. |
|
Seeking, the thumbnail filter, scene detection, sprite sheets, rotation, and BlurHash on the cover. |
|
Progressive versus adaptive streaming, playlists, segment length, FFmpeg and packagers, CDN delivery, signed cookies and DRM. |
|
Thumbnailator, imgscalr (legacy), TwelveMonkeys, Scrimage, libvips bindings, blurhash-java, Jaffree and JAVE2. |
|
A media service with pre-signed uploads, a queue, workers, a status endpoint and Spring Batch backfills, in both frameworks. |
|
Pillow, pillow-heif, pyvips, BlurHash, ffmpeg-python, MoviePy 2, subprocess and a FastAPI upload endpoint. |
|
sharp, Jimp, blurhash, fluent-ffmpeg (legacy), a NestJS and BullMQ example, and Rust with axum, the image crate and tokio. |
|
ImageSharp and its license, SkiaSharp, NetVips, BlurHash, FFMpegCore, Xabe.FFmpeg and an ASP.NET Core upload endpoint. |
|
The reference architecture: pre-signed uploads, events, queues, idempotent workers, retries, dead-letter queues and status. |
|
Upload validation, decompression bombs, metadata stripping, sandboxing FFmpeg, patching, cost, lifecycle and monitoring. |
|
A one-page summary of formats, BlurHash, FFmpeg commands, the ladder and a library picker. |
Reading paths
-
Images only. Start with formats, then variants, then BlurHash, then the page for your language.
-
Video. Read encoding, streaming and covers, then decide between self-hosted FFmpeg workers and a managed transcoder, see below.
-
A new platform. Read upload pipelines first, since it fixes the architecture the other pages fit into, and security and operations before the first public upload.
Existing pages this section builds on
-
Storage: File Storage and Object Stores, NestJS file upload and streaming and FastAPI forms and file uploads.
-
Queues and jobs: Messaging, Scheduling, Spring Batch, Quarkus messaging, NestJS queues and FastAPI background tasks.
-
Running workers: Docker and Kubernetes Jobs.
Managed alternatives in the cloud
Self-hosted FFmpeg and image workers are one choice. Each cloud offers a managed one, described in its own section:
-
AWS: Elemental MediaConvert, S3 and Lambda image processing, CloudFront delivery and a Video on Demand pipeline.
-
Google Cloud: the Transcoder API, Cloud Run jobs, Media CDN and storage-triggered resizing.
-
Azure: Media Services was retired, so self-hosted FFmpeg in Container Apps jobs, Event Grid with Functions, and Front Door.
The frontend counterparts are Media Optimization for the web and Media Optimization in apps.
Bibliography
Every source below is the official site, repository or documentation page of the library, service or standard it supports. Links were checked from an authoring environment with restricted outbound access. Entries marked (unverified) could not be opened from there (the site refused or blocked the request), so open them and confirm the content, version and status before you rely on them. Entries without the mark were opened successfully, or, for package pages, confirmed through the package registry.
BlurHash and ThumbHash
-
blurha.sh (unverified)
-
Blurhash.ImageSharp and blurhash.net (unverified)
-
BlurHashSharp (unverified)
-
docs.rs, blurhash (unverified)
-
halcy/blurhash-python (unverified)
-
hsch/blurhash-java (unverified)
-
ThumbHash (unverified)
-
vanniktech/blurhash (unverified)
-
woltapp/blurhash, Algorithm.md (unverified)
-
woltapp/blurhash, Kotlin implementation (unverified)
-
woltapp/blurhash, list of implementations (unverified)
-
woltapp/blurhash, reference TypeScript code (unverified)
-
woltapp/blurhash, Swift implementation (unverified)
-
woltapp/blurhash, the reference BlurHash repository (unverified)
-
woltapp/blurhash-python (unverified)
Image formats, encoders and libvips
-
AV1 Image File Format specification (unverified)
-
Can I use (unverified)
-
Cloudinary (unverified)
-
Google, cwebp documentation (unverified)
-
imgix (unverified)
-
JPEG, JPEG XL overview (unverified)
-
libavif, AVIF encoder and decoder (unverified)
-
libjxl, JPEG XL reference implementation (unverified)
-
libvips, API documentation (unverified)
-
libvips, command line interface (unverified)
-
libvips, heifsave (unverified)
-
MDN, Cache-Control header (unverified)
-
MDN, HTTP caching (unverified)
-
MDN, image file type and format guide (unverified)
-
MDN, responsive images (unverified)
-
pyvips (unverified)
-
pyvips documentation (unverified)
-
VMAF (unverified)
Java
-
AWS SDK for Java, presigned URLs (unverified)
-
imgscalr (unverified)
-
Jaffree (unverified)
-
Javadoc (unverified)
-
JAVE2 (unverified)
-
JVips (unverified)
-
Quarkus RabbitMQ connector (unverified)
-
Quarkus, building a native executable (unverified)
-
Scrimage (unverified)
-
Spring Framework data access (unverified)
-
Thumbnailator (unverified)
-
TwelveMonkeys ImageIO (unverified)
-
vips-ffm (unverified)
-
webp-imageio (unverified)
Python
-
FastAPI, background tasks (unverified)
-
FastAPI, request files (unverified)
-
ffmpeg-python (unverified)
-
ImageOps (unverified)
-
MoviePy (unverified)
-
MoviePy documentation (unverified)
-
Pillow (unverified)
-
Pillow image file formats (unverified)
-
pillow-avif-plugin (unverified)
-
pillow-heif (unverified)
-
pillow-heif documentation (unverified)
-
Python subprocess (unverified)
Node.js
-
BullMQ documentation (unverified)
-
fluent-ffmpeg (unverified)
-
Jimp (unverified)
-
Jimp documentation (unverified)
-
NestJS queues (unverified)
-
sharp (unverified)
-
sharp, input and metadata API (unverified)
-
sharp, output API (unverified)
-
sharp, resize API (unverified)
Rust
-
axum (unverified)
-
docs.rs, axum (unverified)
-
docs.rs, image (unverified)
-
docs.rs, tokio::process (unverified)
.NET
-
Background tasks with hosted services in ASP.NET Core (unverified)
-
FFMpegCore (unverified)
-
ImageSharp (unverified)
-
ImageSharp documentation (unverified)
-
NetVips (unverified)
-
NetVips documentation (unverified)
-
SkiaSharp (unverified)
-
SkiaSharp API documentation (unverified)
-
System.Threading.Channels (unverified)
-
Xabe.FFmpeg (unverified)
-
Xabe.FFmpeg (unverified)
Video, FFmpeg and streaming
-
Bento4 (unverified)
-
DASH Industry Forum (unverified)
-
FFmpeg wiki, Encode/H.264 (unverified)
-
FFmpeg wiki, Seeking (unverified)
-
FFmpeg, codecs documentation (unverified)
-
FFmpeg, hls muxer (unverified)
-
FFmpeg, main options (unverified)
-
FFmpeg, thumbnail filter (unverified)
-
MDN, web video codec guide (unverified)
-
RFC 8216 (unverified)
-
Shaka Packager (unverified)
Security
-
NVD, CVE-2023-4863 (libwebp heap buffer overflow) (unverified)
Other sources
-
Expo, expo-image documentation (unverified)
-
unlazy (unverified)
-
MDN, picture element (unverified)