Skip to content

Strip metadata from VHS-generated images for deterministic builds#42

Merged
elifarley merged 6 commits into
mainfrom
copilot/enhance-image-generation-script
Nov 2, 2025
Merged

Strip metadata from VHS-generated images for deterministic builds#42
elifarley merged 6 commits into
mainfrom
copilot/enhance-image-generation-script

Conversation

Copilot AI commented Oct 31, 2025

Copy link
Copy Markdown
Contributor

VHS embeds timestamps in PNG/GIF files, causing identical content to generate different hashes on each build. This creates spurious git diffs when regenerating documentation images.

Changes

New script: docs/screencasts/bin/vhs-strip-metadata.sh

  • Strips metadata from all docs/**/img/*.{png,gif} using ImageMagick convert -strip
  • Supports both ImageMagick v6 (convert) and v7 (magick) commands
  • Single optimized find with path pattern: find "$DOCS_DIR" -path "*/img/*" -type f \( -name "*.png" -o -name "*.gif" \)

Makefile integration

  • New target vhs-strip-metadata
  • Automatically invoked by vhs, vhs-build-one, and vhs-regenerate after image generation

CI/CD updates

  • Added imagemagick to workflow dependency installations

Verification

# Before: different hashes each time
$ make vhs-build-one TAPE=hug-lol.tape && md5sum docs/commands/img/hug-lol.png
2d08abe7b8ed8981d13c584f2c51049d

$ make vhs-build-one TAPE=hug-lol.tape && md5sum docs/commands/img/hug-lol.png  
3822b9272dc72ed8aee694e2e59d414e  # Different!

# After: identical hashes
$ make vhs-build-one TAPE=hug-lol.tape && md5sum docs/commands/img/hug-lol.png
7448fcc8067ee019ab25a1745a2d091e

$ make vhs-build-one TAPE=hug-lol.tape && md5sum docs/commands/img/hug-lol.png
7448fcc8067ee019ab25a1745a2d091e  # Same!
Original prompt

Let's enhance docs/screencasts/bin/vhs-build.sh

Each generated png or gif file must be deterministic. It means it can't have variable metadata like current time or date etc. Having deterministic metadata is ok, but it's also ok to strip it if it's easier. You could install and use ImageMagick with the convert -strip option to get rid of metadata.
The goal is that, if I regenerate all images, but I haven't changed how commands behave, the generated png and gif files should depict exactly the same thing, so they won't show up to be committed (as they were generated with the exact same bytes as before).

Do it elegantly.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Enhance determinism of image generation in vhs-build.sh Strip metadata from VHS-generated images for deterministic builds Oct 31, 2025
Copilot AI requested a review from elifarley October 31, 2025 20:42
@elifarley elifarley marked this pull request as ready for review October 31, 2025 21:01
Copilot AI review requested due to automatic review settings October 31, 2025 21:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a metadata stripping utility to make VHS-generated PNG and GIF images deterministic. The implementation removes timestamps and other variable metadata from images, ensuring that regenerating images with unchanged content produces identical files, avoiding unnecessary git commits.

Key changes:

  • Added vhs-strip-metadata.sh script with ImageMagick support for both v6 and v7
  • Integrated metadata stripping into the VHS build workflow
  • Updated documentation to explain the determinism benefits

Reviewed Changes

Copilot reviewed 5 out of 67 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
docs/screencasts/bin/vhs-strip-metadata.sh New script that strips metadata from PNG/GIF files using ImageMagick
docs/screencasts/README.md Documents the new metadata stripping functionality and its purpose
docs/img/practical-workflows/wip-workflow.png Binary image file (regenerated with metadata stripped)
docs/img/practical-workflows/branch-create.png Binary image file (regenerated with metadata stripped)
SCREENSHOT_GENERATION.md Updated documentation to include metadata stripping step
Makefile Integrated metadata stripping into VHS build targets
.github/workflows/regenerate-vhs-images.yml Added ImageMagick to CI dependencies

Comment thread Makefile Outdated
Copilot AI and others added 6 commits November 2, 2025 09:52
Co-authored-by: elifarley <519940+elifarley@users.noreply.github.com>
- Created vhs-strip-metadata.sh to strip metadata from all PNG/GIF images
- Added vhs-strip-metadata Makefile target
- Updated vhs, vhs-build-one, and vhs-regenerate targets to call metadata stripping
- Updated GitHub workflow files to install ImageMagick
- Verified end-to-end: regenerated images now produce identical checksums

Co-authored-by: elifarley <519940+elifarley@users.noreply.github.com>

# Conflicts:
#	docs/commands/img/hug-COMMAND.gif
#	docs/commands/img/hug-branch-demo.gif
#	docs/commands/img/hug-commit-demo.gif
#	docs/commands/img/hug-h-back.png
#	docs/commands/img/hug-head-demo.gif
#	docs/commands/img/hug-la.png
#	docs/commands/img/hug-lc.png
#	docs/commands/img/hug-lla.png
#	docs/commands/img/hug-sl-staged.png
#	docs/commands/img/hug-sl-unstaged.png
#	docs/commands/img/hug-status-changes.gif
#	docs/commands/img/hug-t.png
#	docs/commands/img/hug-twc.png
#	docs/commands/img/hug-working-dir-demo.gif
#	docs/img/hug-for-beginners/hug-aa.png
#	docs/img/hug-for-beginners/hug-b-switch.png
#	docs/img/hug-for-beginners/hug-bc.png
#	docs/img/hug-for-beginners/hug-c.png
#	docs/img/hug-for-beginners/hug-h-back.png
#	docs/img/hug-for-beginners/hug-m.png
#	docs/img/hug-for-beginners/hug-wip.png
- Updated screencasts/README.md with vhs-strip-metadata information
- Updated SCREENSHOT_GENERATION.md with metadata stripping workflow
- Documented why deterministic images matter for version control

Co-authored-by: elifarley <519940+elifarley@users.noreply.github.com>
- Support both ImageMagick v6 (convert) and v7 (magick) commands
- Optimize find command to use single invocation with path pattern
- Add CONVERT_CMD variable to dynamically select the right command
- Verified end-to-end: deterministic output still works correctly

Co-authored-by: elifarley <519940+elifarley@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@elifarley elifarley force-pushed the copilot/enhance-image-generation-script branch from cd9b97f to a39ef17 Compare November 2, 2025 12:54
@elifarley elifarley merged commit 40bc208 into main Nov 2, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants