Skip to content

fix: restore initial crop selection for uploaded signatures - #9528

Open
vitormattos wants to merge 5 commits into
mainfrom
fix/9526-signature-upload-stencil-size
Open

vitormattos wants to merge 5 commits into
mainfrom
fix/9526-signature-upload-stencil-size

Conversation

@vitormattos

@vitormattos vitormattos commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Closes #9526

Root cause

FileUpload.vue passed a fixed-size defaultSize object derived from the display container to vue-advanced-cropper. The cropper interprets it in source-image coordinates rather than CSS pixels, causing a tiny initial stencil with high-resolution uploads.

Fix

  • Delegate initial selection dimensions to the cropper's native image-relative algorithm.
  • Retain the configured signature aspect ratio (signature-width / signature-height), the PNG result and existing zoom controls.
  • Remove the obsolete ResizeObserver, container-width sizing code and stale assertions.
  • Preserve state-reset assertions and add a regression test for the cropper's initial props.

Verified red → green regression

Before the fix — 2d02d914d8d707fa2573e5a5e68587b002dd78ec:

  • Node tests run 44085839150 successfully built, then failed in the new test (1 failed, 3,675 passed).
  • Actual: defaultSize = {width: 700, height: 200}. Expected: no fixed defaultSize.

After the fix — 5683304f1b61f4cf4581cfee98ff2da8df77e109:

  • Node tests run 44086404214: 283 test files, 3,675 tests passed, including the regression; coverage step passed.
  • TypeScript type checking, ESLint, stylelint, and JavaScript build: passed.
  • Other CI jobs (including Playwright) may still be in progress and must be inspected before merge.

PHP image quality and scope

SignatureBackgroundService::scaleDimensions() already preserves smaller stamp-background images and proportionally downsizes images larger than 3× the configured full stamp dimensions; SignatureBackgroundServiceTest covers both cases. This is the stamp background, not the user's cropped signature. The latter is validated as PNG (including a 5 MiB size limit) in FileInputValidator and stored by SignerElementsService. The signing engine controls final PDF rendering.

No PHP image processing, resolution rules or file validation are changed by this PR.

Validation limitation

The regression checks the Vue component's integration contract with the cropper and the preserved aspect ratio. It does not assert actual CSS-frame measurements in a real browser using a 3000×1200 image; those measurements were supplied in the original issue report.

Both commits were made with signed DCO trailers.

Follow-up from code review (2026-11-18)

The original change fixes the initial stencil, but a high-entropy 3000 px image can now export a PNG larger than the backend's 5000 KiB visible-element limit.

  • Regression test: 5fd31e3.
  • Fix: b5bb0d2.
  • The cropper's export canvas is limited to 3× the configured signature width/height and 1,000,000 pixels total. No forced output width or height is configured, so smaller images retain their resolution. The megapixel limit also bounds uncompressed RGBA pixel data to around 4 MB, below the current 5000 KiB backend PNG limit, even when compression is ineffective.
  • The new unit test verifies that the application passes these constraints to the cropper. It is not a real-browser validation of the exported PNG or the visible crop frame.
  • At b5bb0d2, NPM lint failed on @stylistic/multiline-ternary at FileUpload.vue:218,220, while the Node tests passed. Both ESLint formatting errors were addressed in 4c2cc7d, a signed DCO commit without a logic change. The new CI for this head is running; it must finish before merge.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@vitormattos
vitormattos marked this pull request as ready for review November 17, 2026 12:51
@vitormattos
vitormattos requested a review from a team as a code owner November 17, 2026 12:51
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

Signature upload: crop frame is fixed at 350×100 *image pixels*, so it is tiny on any real photo or scan

1 participant