[#82] Input long-edge cap (max_input_edge_px, default 1280) before tracing#83
Merged
Conversation
…acing Downscale a large input so its longest edge is at most max_input_edge_px (LANCZOS, aspect-preserved, only when larger, never upscales) before any classify/preprocess/ trace, so CLI/API/web share one behavior. Default 1280: on the flat/illustration target this yields a cleaner, more economical trace (excess resolution + JPEG/upscale noise fragment the trace) with no visible detail loss vs full-res, and ~30% faster. 0 disables (full resolution). The Report records original->effective size for audit. CLI: --max-input-edge-px N. Distinct from a host reject-cap: this RESIZES, not rejects. Bump 0.7.0 -> 0.8.0 (behavior change). svgsmith-x402 will pass this option instead of its own pre-resize. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Owner
Author
|
Sub-PO review OK. No findings. I checked placement before classify/preprocess/trace, report warning behavior, CLI option wiring, version source, and the transparent_background full-res mask note. Local validation: ruff clean; pytest 127 passed / 1 skipped; explicit 2048x1024 -> 1280x640 transparent-background smoke confirmed corners transparent and subject preserved. GitHub CI is green on 3.11 and 3.12, PR is mergeable.\n\nNote: GitHub would not allow a formal approval because this session is authenticated as the PR author account. |
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.
Fixes #82.
What
Add
ConvertOptions.max_input_edge_px: int = 1280: downscale the input so its longest edge ≤ N px before any classify/preprocess/trace (LANCZOS, aspect-preserved, only when larger, never upscales), so CLI/API/web share one behavior.0disables (full resolution). TheReportrecordsoriginal->effectivesize for audit. CLI:--max-input-edge-px N.Bump
0.7.0 → 0.8.0(behavior change).Why
On svgsmith's target (flat/illustration/logo art) excess resolution + JPEG/AI-upscale noise fragment the trace. Downscaling to ~1280 gives a cleaner, more economical trace, ~30% faster, with no visible detail loss vs 1536/full-res — validated on 5 Midjourney samples incl. high-zoom on hair/face + feather pattern (SSIM delta +0.002–0.004 = staircase noise; eye prefers 1280). Also bounds host cost (the x402 API hit a 120s timeout on large inputs).
High-detail→SVG is a weak niche, so this is default-on with a
0opt-out. Naming/opt-out picked with the agent-user perspective (single numeric knob,_pxsuffix).Distinct from a host's reject-cap (e.g. the API's
max_image_px, which rejects oversized uploads): this resizes, it does not reject.Verification
ruffclean; full pytest green (incl. a newtest_max_input_edge_px_downscales_large_inputcovering downscale + aspect + Report note +0disables + below-cap passthrough + negative-rejected).Follow-up (separate)
svgsmith-x402 API will drop its own
_downscale_if_largepre-resize and passmax_input_edge_pxonce 0.8.0 is on PyPI (one place owns the cap).🤖 Generated with Claude Code