Repository navigation
fix: distant photos, upload pixel limit, crop warning and unreachable-server errors - #247
Merged
Merged
Conversation
The corner step rendered the whole visible frame at 10 px/mm and then shrank it to the stored size. That intermediate grows as the sheet shrinks in the photo: a sheet filling a quarter of the frame is over 100 megapixels. The upload pixel limit was applied to it as well, so those photos were rejected with "image has N pixels; maximum is 64,000,000". With the limit raised the step held the intermediate in memory twice, about 0.7 GB for 120 megapixels. Warp straight to the stored size and return the matching scale. The upload pixel limit now covers uploaded photos and masks only. Relates to #244 Signed-off-by: Jason Madigan <jason@jasonmadigan.com>
Reading the focal length ran before the pixel limit. Pillow decodes a whole PNG to look for its EXIF, so a 450 KB, 144 megapixel PNG cost about 580 MB before it was rejected. The limit is now checked first. Pillow also refuses any image above twice its own cap, about 179 megapixels, so a MAX_IMAGE_PIXELS above that never took effect. ingest_image now lifts that cap to a higher configured limit. It never lowers it, since stored images outgrow a small upload limit. Relates to #244 Signed-off-by: Jason Madigan <jason@jasonmadigan.com>
… frame The estimate treats the image as the whole frame the camera took. A cropped photo keeps its focal length, so the sheet looks larger on the sensor than it was and the camera reads closer by the crop factor, 3.6 times for the photo in #244. A capture crop is now undone before estimating. A photo whose EXIF records a different pixel size than the file has was cropped or resized after capture, and the check is skipped for it. An editor that rewrites the EXIF size still hides the crop. Relates to #244 Signed-off-by: Jason Madigan <jason@jasonmadigan.com>
When the backend is down, still starting, killed or slow, nginx answers with an HTML error page. The frontend showed every such response as "request failed" and rendered the app as if it were healthy, while nginx wrote the reason to a file inside the container. Error responses without a detail now name their HTTP status. The app shell shows an alert while the auth status check fails with a network error or a 5xx, and retries every five seconds until it clears. nginx logs errors to stderr, so they reach the container log. Relates to #244 Signed-off-by: Jason Madigan <jason@jasonmadigan.com>
jasonmadigan
marked this pull request as ready for review
November 10, 2026 15:32
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.
Summary
Four fixes for what #244 ran into, one commit each.
1. Distant photos rejected at the corner step
The corner step drew the whole visible frame at 10 px/mm, then shrank it to the stored 2048 px. That intermediate grows as the sheet shrinks in the photo, and the upload pixel limit was applied to it. A sheet filling a quarter of the frame comes to over 100 megapixels, so the photo was rejected with the oversized-upload message,
image has N pixels; maximum is 64,000,000. A 24 to 26 mm phone camera reaches that at about 64 to 69 cm, inside the 60 cm or higher the photo warning asks for.2. Pixel limit checked late, and capped by Pillow
An oversized PNG was decoded in full before it was rejected. Separately, Pillow refuses anything above about 179 megapixels, so a higher
MAX_IMAGE_PIXELSnever took effect.3. Camera distance warning on cropped photos
The estimate treats the image as the whole frame the camera took. A cropped photo keeps its focal length, so the camera reads closer by the crop factor. A capture crop is now undone before estimating, and the check is skipped when the EXIF pixel size differs from the file's, as after a crop or resize elsewhere. An editor that rewrites the EXIF size still hides the crop.
4. Unreachable server shown as "request failed"
When the backend is down, still starting, killed or slow, nginx answers with an HTML error page. The frontend showed each as
request failed, rendered the app as if it were healthy, and nginx wrote the reason to a file inside the container.User-visible changes
MAX_IMAGE_PIXELSabove about 179 megapixels takes effect.Relates to #244. What made the request fail there after
MAX_IMAGE_PIXELSwas raised is not established; 1 removes the need to raise it and 4 makes that kind of failure readable.Evidence
Before is the 0.10.1 image, after is an image built from this branch.
POST /api/sessions/{id}/corners:413 {"detail":"image has 119,961,898 pixels; maximum is 64,000,000"}. WithMAX_IMAGE_PIXELS=200000000: 200 in 0.92 s, container memory peaking at 1.44 GiB against 0.72 GiB idle.After: 200 in 0.04 s, 1781x2048 at 0.5735 mm/px. Against the 0.10.1 output for the same corners: same dimensions, mean absolute difference 1.0/255, scale factor 0.006% apart.
POST /api/upload:After: 413 after 0.01 s, peak unchanged.
MAX_IMAGE_PIXELS=400000000. Before:413 {"detail":"image dimensions exceed the configured limit"}. After: 200.Camera looks about 35 cm from the paper.After: no warning. A photo with EXIF size 3072x4096 in an 887x1089 file stores no focal length.
frontend/e2e/fixtures/tool.jpgis a real case: EXIF records 5712x4284, the file is 3890x5047.request failed, the container log has no line for the 502.After: the alert above shows, an upload shows
server unavailable (HTTP 502), and the container log carries nginx'sconnect() failed (111: Connection refused) while connecting to upstreamunder the default user,--userandPUID/PGID./setup. Checked in Chromium, light and dark.Tests added: 7 for the corner step, 3 for the pixel limit, 9 for the camera distance check, 24 for the frontend. Those for new behaviour were watched failing first.
Ran on Python 3.12.10, Pillow 13.0.0, OpenCV 5.0.0, Node 22.20.0:
make lint: passed, 9 existing frontend warningscd backend && venv/bin/python -m pytest: 871 passedcd frontend && pnpm test: 299 passedmake test-e2e-accuracy: 5 passedmake test-e2e: 23 passeddocker build, thentests/test_entrypoint.shin the image: 16 passedMerge Danger
Door: two-way. No stored data changes shape; each commit reverts on its own.
Blast Radius: calibration. Every traced outline is scaled by the mm per px the corner step returns, so an error there would scale every new trace wrongly. The photo-to-STL size tests (8 cases within 1 mm) and the browser accuracy suite cover that path. The other three are narrower: upload acceptance, one advisory warning, and error text plus container logging.