Skip to content

Add media compression workflow - #290

Open
MUFFANUJ wants to merge 8 commits into
jupyterlab:mainfrom
MUFFANUJ:addCompressionWorkflow
Open

Add media compression workflow#290
MUFFANUJ wants to merge 8 commits into
jupyterlab:mainfrom
MUFFANUJ:addCompressionWorkflow

Conversation

@MUFFANUJ

@MUFFANUJ MUFFANUJ commented Apr 5, 2026

Copy link
Copy Markdown
Member

closes #289

This PR adds a new CI workflow to enforce media optimization. On pull requests to main, it compresses changed png/gif/mp4 files, uploads optimized outputs as the compressed-media-assets artifact, and fails the check when compression updates are detected so they can be included in the PR. It also provides a workflow_dispatch trigger to run the same compression check across all tracked media files for one-time repository backfill.

@MUFFANUJ MUFFANUJ added the enhancement New feature or request label Apr 5, 2026
@MUFFANUJ MUFFANUJ self-assigned this Apr 5, 2026
@MUFFANUJ
MUFFANUJ marked this pull request as draft April 5, 2026 22:21
@MUFFANUJ

MUFFANUJ commented Apr 6, 2026

Copy link
Copy Markdown
Member Author

This PR adds stronger media compression checks in CI: non-snapshot PNGs are compressed with pngquant (with optipng fallback), *-snapshots/*.png remain lossless to reduce visual-test drift, GIFs are compressed with gifsicle --lossy=120 --colors 128, and MP4s are compressed with ffmpeg (crf=32, fps=20, scaled to fit within 1280x720 while preserving aspect ratio). The workflow uploads optimized artifacts and fails when compressible changes are detected so the optimized outputs can be applied in the PR. It also introduces .github/media-compression.lock (path + SHA-256) to make behavior deterministic: files already matching the lock are skipped, and when CI compresses a file it updates the lock entry and includes the updated lockfile in the artifact, so applying the artifact and pushing prevents repeat fail loops on the same files. On the same ~16.42 MB media set, research runs showed conservative lossless compression to ~15.08 MB (save ~1.34 MB, 8.16%), moderate lossy to ~11.95 MB (save ~4.47 MB, 27.25%), and aggressive lossy to ~9.7–9.8 MB (save ~6.6–6.7 MB, ~40%). This workflow uses the aggressive lossy profile in CI.

@MUFFANUJ
MUFFANUJ marked this pull request as ready for review April 6, 2026 12:29
@krassowski

Copy link
Copy Markdown
Member

I think that media-compression.lock adds too much overhead to maintaining this repository (adding new examples/modifying existing ones). Could we only run exclusively lossless compression instead? At least with optipng this should stabilise at a stable binary form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Todo
Status: No status

Development

Successfully merging this pull request may close these issues.

Add CI workflow to compress media assets

2 participants