A fractional width like `width=600.5` returns the full 1200x630 image
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 88/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- typescript
Rechercherichtung
Lies resolveDimensions in src/lib/api-validation.ts und die Tests in tests/api/og.test.ts; das Issue benennt den Pfad für gebrochene Breiten und die erwarteten Abmessungen. Ergänze Tests für gebrochene Breiten im Dimensionsresolver und in der API-Route und stelle dann sicher, dass die aufgeführten Check-, Test- und Build-Befehle erfolgreich sind. Fertig ist die Aufgabe, wenn die Antworten für gebrochene Breiten den Abnahmekriterien entsprechen und das bestehende Verhalten bei ganzzahligen Breiten und gebrochenen Höhen erhalten bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
On dev, /api/og?width=600 returns a 600x315 PNG, but /api/og?width=600.5 returns 1200x630, and so does width=333.3. Run npm run dev and open http://localhost:4321/api/og?width=600.5 to see it.
The schema accepts any number from 200 to 2400 (src/lib/api-validation.ts, lines 16 to 19), and resolveDimensions (line 46) keeps the fraction. src/pages/api/og.ts passes the width to the renderer as scaleDown (line 82), which becomes resvg's fitTo width (src/lib/og-engine.ts, lines 88 to 91). resvg-wasm 2.6.2 ignores a fitTo width that isn't a whole number and renders the SVG at its own size, 1200x630. width=600.0 works because it parses to 600.
A fractional height on its own is fine, because the width derived from it is rounded (line 74): height=315.5 gives 601x316.
This came in with #142 (the fix for #85), which isn't released yet. Production still runs v1.6.0, where width crops the canvas instead of scaling it, and there width=600.5 gives a 601x630 image. The next release is planned for Friday, so it would be good to fix this before then.
What to do
- Round the width to a whole number at the start of
resolveDimensions. Thenwidth=600.5works likewidth=601and gives 601x316. The height doesn't need it: only the width goes to the renderer, and a width derived fromheightis already rounded. - Round instead of rejecting fractions with
.int(). Production acceptswidth=600.5today and returns an image, so a 400 would break URLs that work now.
Where to look
src/lib/api-validation.ts: thewidthandheightschema (lines 16 to 23) andresolveDimensions(lines 46 to 96)src/pages/api/og.ts:scaleDown(line 82)src/lib/og-engine.ts:fitTo(lines 88 to 91)tests/api/og.test.ts: theresolveDimensionstests (line 102) and the route tests for sizes (line 361)
Acceptance criteria
-
/api/og?width=600.5returns a 601x316 PNG, andwidth=333.3returns 333x175 -
height=315.5still returns 601x316, and whole numbers work as before - Tests for fractional widths in
resolveDimensionsand in the route -
npm run check,npm run testandnpm run buildpass
Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off dev, and open your PR against dev with Closes #167 in the description.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 8
- Forks
- 4
- Ø Merge
- 5 Std. 44 Min.
- Gemergte PRs (30 T.)
- 83
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus codercops/ogcops
-
Add the Order Status e-commerce template (`ecommerce-order-status`)Evtl. vergeben @piyusshhjangid hat das heute übernommen. Offengood first issue hacktoberfest templates
codercops/ogcops#181 · 4 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Add the Cheat Sheet tutorial template (`tutorial-cheat-sheet`)Evtl. vergeben @srikar-naidu hat das heute übernommen. Offenhacktoberfest help wanted templates
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 45/100
codercops/ogcops#180 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Add the Call for Speakers event template (`event-call-for-speakers`)Evtl. vergeben @Saifjafri212213 hat das heute übernommen. Offengood first issue hacktoberfest templates
codercops/ogcops#177 · 2 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Add the Day Streak developer template (`developer-day-streak`)Evtl. vergeben @srikar-naidu hat das heute übernommen. Offenhacktoberfest help wanted templates
codercops/ogcops#176 · 3 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
hacktoberfest
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 35/100
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in codercops/ogcops
Ähnliche Issues
-
area:agent-view area:tui bug platform:macos
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
anthropics/claude-code#104558 ·
Maintainer antworten meist innerhalb von 1 Tag
-
updater
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
UniversityOfHelsinkiCS/oodikone#5141 ·
-
maintanance
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
inmanta/web-console#7606 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug skills
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 77/100
equinor/fusion-framework#5846 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 74/100