Skip to content

[#82] Input long-edge cap (max_input_edge_px, default 1280) before tracing#83

Merged
realproject7 merged 1 commit into
mainfrom
task/82-max-input-edge-px
Jun 30, 2026
Merged

[#82] Input long-edge cap (max_input_edge_px, default 1280) before tracing#83
realproject7 merged 1 commit into
mainfrom
task/82-max-input-edge-px

Conversation

@realproject7

Copy link
Copy Markdown
Owner

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. 0 disables (full resolution). The Report records original->effective size 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 0 opt-out. Naming/opt-out picked with the agent-user perspective (single numeric knob, _px suffix).

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

ruff clean; full pytest green (incl. a new test_max_input_edge_px_downscales_large_input covering downscale + aspect + Report note + 0 disables + below-cap passthrough + negative-rejected).

Follow-up (separate)

svgsmith-x402 API will drop its own _downscale_if_large pre-resize and pass max_input_edge_px once 0.8.0 is on PyPI (one place owns the cap).

🤖 Generated with Claude Code

…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>
@realproject7

Copy link
Copy Markdown
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.

@realproject7 realproject7 merged commit a121aa3 into main Jun 30, 2026
4 checks passed
@realproject7 realproject7 deleted the task/82-max-input-edge-px branch June 30, 2026 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat] Input long-edge cap (max_input_edge_px, default 1280) for cleaner/faster traces

1 participant