Skip to content

fix: Failed scaling of uploaded signature - #8002

Open
Roshan931 wants to merge 2 commits into
LibreSign:mainfrom
Roshan931:prilog/fix-error-uploaded-signature-png-is-composited-at-08-21-2026-5a3360
Open

fix: Failed scaling of uploaded signature#8002
Roshan931 wants to merge 2 commits into
LibreSign:mainfrom
Roshan931:prilog/fix-error-uploaded-signature-png-is-composited-at-08-21-2026-5a3360

Conversation

@Roshan931

Copy link
Copy Markdown
Contributor

Fixes #7981

Root cause

Uploaded signature PNG is composited at pixel-size × scale factor instead of being fitted into the stamp box

Changes

  • Resize the user signature with Imagick bestfit into the stamp canvas (same aspect-preserving approach already used for the background in prepareBackgroundForPdf) instead of multiplying its own pixel dimensions by the scale factor, plus a regression test asserting the whole signature stays inside the merged canvas.

@welcome

welcome Bot commented Aug 21, 2026

Copy link
Copy Markdown

Thanks for opening your first pull request in this repository! ✌️

@github-project-automation github-project-automation Bot moved this to 0. Backlog in Roadmap Aug 21, 2026
$mergedPath = self::invokePrivate($this->getInstance(), 'mergeBackgroundWithSignature', [
$backgroundPath,
$signaturePath,
5.0,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be best to use the constant SCALE_FACTOR_MIN because duplicating the value here couples the test to that implementation detail. Ideally the test should exercise the behavior without needing to know the exact minimum value.

$this->assertStringNotContainsString(' -cl ' . DocMdpLevel::CERTIFIED_FORM_FILLING_AND_ANNOTATIONS->name, $paramsSeen[0]);
}

public function testMergeBackgroundWithSignatureFitsOversizedSignatureInsideStampBox(): void {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be good to use #[DataProvider('signatureDimensionsProvider')] here to cover different aspect ratios:

public static function signatureDimensionsProvider(): array {
	return [
		'same aspect ratio' => [1400, 400],
		'wider signature' => [1400, 200],
		'taller signature' => [700, 800],
	];
}

This would keep the regression case and also verify the new behavior with wider and taller signatures.

@github-project-automation github-project-automation Bot moved this from 0. Backlog to 1. to do in Roadmap Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 1. to do

Development

Successfully merging this pull request may close these issues.

Failed scaling of uploaded signature

2 participants