Repository navigation
feat: skip PNG renders whose source has not changed - #147
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
brand.build.rendernow leaves a PNG alone when the SVG it comes from hasn't changed. Before this, every run rewrote all ~110 committed PNGs, because rsvg-convert output differs byte-wise between machines. Each brand PR then had to revert them by hand, and #145 ended up committing them.export_pnghashes the SVG bytes, the requested width and height, and the palette size, and stores the hash in asource-sha256text chunk inside the PNG. On the next run it reads the chunk back and skips rsvg-convert when the hash matches. A changed SVG, size or palette re-renders as before. Without Pillow there is no chunk, so every PNG renders as it does today.The second commit re-renders every PNG once to add the chunk. That is the one-time churn: 113 files under
brand/plus thedocs/assetscopy of the green social card. I compared each of them to main after decoding and all are pixel-identical; only the metadata differs. A second render right after touched no files.A newer rsvg-convert won't re-render anything on its own. To force it, delete the PNGs and run the renderer.
The Pillow import moved to module level, with the same fallback when Pillow is missing.
Tests:
tests/test_raster.pycovers the skip on an unchanged source and the re-render on a changed SVG and on a changed size.uv run pytest(184 passed) anduv run mkdocs build --strictpass locally.