Ask Wikimedia for a rasterized PNG instead of raw SVG#22
Merged
Conversation
After yesterday's librsvg install (#21), the next REP.MC request still hung at processing — turns out the Alpine `vips` package is compiled WITHOUT rsvg support (verified via `vips --vips-config`), so installing librsvg as a runtime lib does nothing. libvips can't load it. Fortunately Wikimedia exposes server-side rasterization via the `Special:FilePath/<file>?width=N` endpoint: when the source is SVG it redirects to a thumbnail-server PNG; when it's already a raster the query param is ignored. Either way, our downstream libvips pipeline only sees PNG bytes — which it handles fine without librsvg. Sandbox-verified: hit Special:FilePath/Repsol_logo.svg?width=512 → HTTP 301 → upload.wikimedia.org/...//960px-Repsol_logo.svg.png → real PNG (960×240, 8-bit RGBA). 512 chosen so the largest output size (xl=256px) downsamples cleanly with headroom. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
What just happened
After yesterday's librsvg install (#21), the very next REP.MC request still hung at processing for ~30s before kamal-proxy 504'd:
```
22:59:16 cache miss for REP.MC
22:59:17 found logo via Wikidata, source=wikidata:Q174747
[504 — no further logs]
```
`kamal app exec --reuse "vips --vips-config | grep rsvg"` returned "no rsvg in vips config" — the Alpine `vips` package was compiled WITHOUT rsvg support. Installing librsvg as a runtime lib does nothing; libvips can't load it.
Fix
Wikimedia rasterizes server-side via `Special:FilePath/?width=N`. Append `?width=512` to the URL and:
Either way, our libvips downstream only sees PNG, which it handles fine.
512 was chosen so the largest output size (xl=256px) downsamples cleanly with quality headroom.
Test plan
🤖 Generated with Claude Code