Fix #116: Size parameter in avatar URLs does not affect image resolution #130
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "typosaurus/ticket-116"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Resolves #116.
Plan
Implementation Plan
Objective: Fix the
sizeparameter for SVG avatar endpoints so that the returned SVG respects the requested pixel dimensions.Changes Required
Modify
generate_avatar_svg()indevplacepy/avatar.pysize: intparameter to the function signature.width="{size}"andheight="{size}"attributes on the root<svg>element.viewBox="0 0 100 100"unchanged so the interior grid scales proportionally.Update the SVG route handler (likely
devplacepy/routers/avatar.py)sizeparameter to the range[16, 512](matching the devRant PNG endpoint).sizetogenerate_avatar_svg().seedtof"{seed}:{size}"for both lookup and storage.ETagheader already usesf"{seed}:{size}"(confirmed correct; may double-check).Add/update test coverage
tests/api/avatar.py, after asserting status 200 and content‑type, verify that the response body containswidth="{requested_size}"andheight="{requested_size}"when?size=is provided.seedwith two distinctsizevalues and asserts that the bodies are not identical (or thatETagvalues differ).avatar_url()still passes (it only checks URL generation, not the wire response).Run project verification commands
pip install -e '.[dev]' -q && make test-unitpip install -q ruff && ruff check .Definition of Done
generate_avatar_svg(seed, size)is modified to acceptsizeand produce an<svg>withwidth="<size>"andheight="<size>".size(16–512) and passes it togenerate_avatar_svg()."{seed}:{size}"(not bareseed).width/heightfor a givensize, and that different sizes produce distinct responses.make test-unit.ruff check .reports zero errors./avatars/u/test.svg?size=32returns SVG withwidth="32" height="32"; same seed with?size=128returns SVG with those different dimensions and a differentETag.Opened automatically by Typosaurus.
Checkout
From your project repository, check out a new branch and test the changes.