Skip to content

Refuse images over the browser canvas size limits on import - #146

Merged
vycdev merged 3 commits into
vycdev:developfrom
officialasishkumar:fix/issue-125-oversized-image-import
Nov 15, 2026
Merged

vycdev merged 3 commits into
vycdev:developfrom
officialasishkumar:fix/issue-125-oversized-image-import

Conversation

@officialasishkumar

@officialasishkumar officialasishkumar commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Importing an image beyond the browser's canvas limits used to replace the working image with a blank preview and leave the app sluggish. This change refuses the file before it enters image history, shows a localized notice with its dimensions and resize advice, and keeps the current image, undo history, and swatches.

The import uses a conservative budget of 268,435,456 pixels and 65,535 pixels per side. iPhone and iPad, including desktop browsing mode, use a lower 16,777,216-pixel budget for compatibility with older Safari versions. The notice recommends 4096×4096 or 16384×16384 as appropriate. Small canvas probes check each axis without allocating a full-size test canvas, so older browsers with lower dimension limits are handled while supported thin panoramas (such as 40000×8) can still load. The probe tolerates small alpha changes from browser fingerprinting protection while still refusing blank or nearly transparent results.

The check stays in the main image import hook. Stack Matrix photos still load through their existing path, which draws them at no more than 1200 pixels. Loading Images and Troubleshooting explain the behavior in all 12 languages, and the unreleased changelog entry includes the final behavior and coverage.

Fixes #125.

Validation:

  • Lint, TypeScript, production build, and i18n checks pass.
  • Unit suite: 1,115 passed, one skipped.
  • Focused Chromium import/reimport tests: 16 passed.
  • Additional desktop WebKit canvas-limit regressions: seven passed.
  • Coverage includes total-area rejection through file picker and drag-drop, iPhone and desktop-mode iPad detection, platform-specific resize advice, silent and throwing dimension failures, valid panoramas in both orientations, privacy noise on both working and blank canvases, and preserved image history.
  • npm run test:e2e:all ran all eight suites. Smoke (90), docs (6), landing (19), 404 (10), i18n (17), and i18n production-build (4) tests all passed. Privacy (9 passed, 4 failed) and terms (6 passed, 4 failed) reproduce only the existing footer-count failures from Privacy and terms e2e footer tests still expect 7 links after the Awards link #143: expected seven links, received eight.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-11T16:08:48.075091Z
We couldn’t complete this review. Comment @codex review to try again.
0d7fe5e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Importing an image larger than a browser canvas can hold, for example a
17000x17000 PNG, appeared to work: the size badge showed the new
dimensions, but the 2D preview stayed blank and the app stayed
unresponsive for minutes. CanvasPreview copies the image into canvases
at full size, and browsers silently refuse canvases over 268,435,456
pixels (16384x16384) in Chromium, the WebView2 desktop app and WebKit,
or with a side over 32,767 pixels in Firefox. The refused canvases stay
blank instead of throwing, so the rest of the pipeline kept working
against unusable canvases (vycdev#125).

useImageImport now reads the decoded size before closing the image and
refuses anything outside both limits, through the same path as
unreadable files: the object URL is revoked, nothing is pushed to image
history, the swatches are left alone, and the dismissible import notice
explains the problem. The check lives in the main import rather than
validateImageFile because the Stack Matrix photo picker also uses that
helper and draws photos at no more than 1200 px, so very large photos
still work there.

- src/lib/imageFile.ts: add MAX_IMAGE_SIDE, MAX_SQUARE_IMAGE_SIDE,
  MAX_IMAGE_PIXELS and fitsImageCanvasLimits, with the per-engine
  limits documented.
- useImageImport: new 'tooLarge' error kind carrying the file name, the
  image size and whether the current image was kept, so the notice
  follows language changes like the existing kinds.
- App: build the notice text in a small helper instead of a nested
  ternary. Every translation key stays a literal for check:i18n.
- Two new strings in all 12 locales name the image size and the
  16384x16384 limit, with and without the "current image was kept"
  sentence.
- Loading Images docs, in all 12 languages, describe the limits.
- Unreleased changelog entry under Fixed.

Tests: unit coverage of the limits at and just past both boundaries,
and a @smoke e2e test that imports a real 32768x8 PNG, generated in the
test, and checks the notice text, the kept image, that history and the
"no image" wording are unchanged, and that a 32767x8 PNG still imports.

Fixes vycdev#125
@officialasishkumar
officialasishkumar force-pushed the fix/issue-125-oversized-image-import branch from 0d7fe5e to 69ebcfd Compare November 11, 2026 16:32
@officialasishkumar

Copy link
Copy Markdown
Contributor Author

The e2e jobs here failed in the "Install Playwright system dependencies" step, before any test ran: the runner couldn't resolve azure.archive.ubuntu.com (Temporary failure resolving), twice in a row. "Lint, build, and unit tests" passed. I can't rerun jobs on this repository, so could you rerun the failed jobs once the runners recover?

@vycdev
vycdev merged commit 31b3881 into vycdev:develop Nov 15, 2026
11 checks passed
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.

2 participants