Skip to content

Strip PNG metadata to ensure deterministic screenshot output#1

Open
EmilioBejasa wants to merge 1 commit intoscreenshotbot:mainfrom
EmilioBejasa:fix/strip-png-metadata
Open

Strip PNG metadata to ensure deterministic screenshot output#1
EmilioBejasa wants to merge 1 commit intoscreenshotbot:mainfrom
EmilioBejasa:fix/strip-png-metadata

Conversation

@EmilioBejasa
Copy link

Summary

  • Add PngMetadataStripper utility to remove non-essential PNG chunks
  • Modify AlbumImpl.writeBitmap() to strip metadata before saving

Problem

Android's Bitmap.compress() adds metadata chunks like tIME (timestamps) to PNG files. This causes byte-level differences between otherwise identical screenshots, which breaks hash-based comparison in Screenshotbot.

When screenshots are visually identical but have different timestamps, Screenshotbot flags them as changed and requires manual approval.

Solution

Strip non-essential PNG chunks (tIME, tEXt, iTXt, etc.) while preserving essential image data (IHDR, IDAT, PLTE, IEND, etc.).

Test plan

  • Compiles successfully
  • Unit tests for PngMetadataStripper
  • Verify screenshots no longer contain tIME chunks

🤖 Generated with Claude Code

Android's Bitmap.compress() adds metadata chunks (like tIME timestamps)
to PNG files. This causes byte-level differences between otherwise
identical screenshots, breaking hash-based comparison in Screenshotbot.

This change adds a PngMetadataStripper utility that removes non-essential
PNG chunks while preserving image data and essential color information.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

1 participant