Repository navigation
fix: keep traced SVGs under the path command limit of laser software - #1920
Marouane-elfadli wants to merge 2 commits into
Conversation
KnifeLemon
left a comment
There was a problem hiding this comment.
Thanks, @Marouane-elfadli! Retrying with coarser settings until the SVG fits is a sensible approach. Halving the picture is also safe: WriteSvg scales from result.Width/Height, so a halved trace still fills the original size.
Blocking: CI fails at dotnet format
windows / build (win-x64) stops at dotnet format Filee.slnx --verify-no-changes --severity warn:
tests/Filee.Engines.Tests/TracingTests.cs(145,25): warning xUnit1051: Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken …
tests/Filee.Engines.Tests/TracingTests.cs(146,23): warning xUnit1051: …
Pass the test's token to both calls:
var unlimited = ImageTracer.Trace(rgba, size, size, settings with { MaxCommands = 0 }, ct: TestContext.Current.CancellationToken);
var limited = ImageTracer.Trace(rgba, size, size, settings, ct: TestContext.Current.CancellationToken);The Linux jobs ran the tests, and they passed.
A question for the maintainer (no change needed yet)
The 40 000 cap applies to every trace, so a detailed trace that someone wants for print or editing gets simplified too, and there's no way to turn it off. We'll confirm whether the cap should stay on by default or become a preset option. Please wait for that answer before reworking anything.
Smaller points (optional)
- After the last round, the result can still be over the budget, yet the SVG comment says "Simplified to N path commands (limit 40000)". It could say when the result didn't fit.
- Each retry traces the whole picture again while the progress stays at 95 %. On a large photo that can mean several full traces. That's fine for now; I'm only noting it.
- A CHANGELOG bullet under Unreleased, with a ko/en pair in the update block, would help. We can add it when merging if you prefer.
The branch starts from an October commit, but it merges into main cleanly, so you don't need to do anything there.
|
Hi @Marouane-elfadli, thanks for waiting. The maintainer has decided: the command budget becomes a tracing option, off by default, rather than applying to every trace. A detailed trace for printing or editing should stay as detailed as it is today, and people sending it to laser or CAD software can turn the budget on. What that means for this PR:
If you'd rather not take this on, just say so and we'll finish it from here, keeping your credit. |
What does this change?
Raster → SVG tracing now keeps the result under a budget of 40,000 path commands. If a trace is over the budget, it is retried with coarser settings (larger specks, looser curves, fewer colours, and finally a reduced working resolution) until it fits. This stops Flux Beam Studio from showing "The file may be too large or complex" and importing a black placeholder instead of the picture. Pictures already under the budget trace exactly as before.
Fixes #1917
Type of change
How was it tested?
dotnet format --verify-no-changesdotnet testAdded a regression test,
Busy_picture_stays_under_the_command_budget, inTracingTests.cs.Screenshots (UI changes)
No UI changes.
Checklist
src/Filee.App/Assets/i18n/*.jsonfiles (no new UI strings)THIRD-PARTY-NOTICES.md(none added)