Skip to content

Commit 892b7f4

Browse files
committed
chore: change scale factor
This will reduce the size of files at server and also the final size of PDF files Signed-off-by: Vitor Mattos <vitor@php.rio>
1 parent cbb964f commit 892b7f4

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

lib/Service/SignatureBackgroundService.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
class SignatureBackgroundService {
2727
use TSimpleFile;
28+
public const SCALE_FACTOR = 3;
2829

2930
public function __construct(
3031
private IAppData $appData,
@@ -86,10 +87,8 @@ private function scaleDimensions(int $width, int $height): array {
8687
$signatureWidth = $this->appConfig->getValueFloat(Application::APP_ID, 'signature_width', SignatureTextService::DEFAULT_SIGNATURE_WIDTH);
8788
$signatureHeight = $this->appConfig->getValueFloat(Application::APP_ID, 'signature_height', SignatureTextService::DEFAULT_SIGNATURE_HEIGHT);
8889

89-
$upscaleFactor = 5;
90-
91-
$maxWidth = $signatureWidth * $upscaleFactor;
92-
$maxHeight = $signatureHeight * $upscaleFactor;
90+
$maxWidth = $signatureWidth * self::SCALE_FACTOR;
91+
$maxHeight = $signatureHeight * self::SCALE_FACTOR;
9392

9493
if ($width <= $maxWidth && $height <= $maxHeight) {
9594
return ['width' => $width, 'height' => $height];

tests/Unit/Service/SignatureBackgroundServiceTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ public static function providerScaleDimensions(): array {
6363
'under limit => return equals' =>
6464
[100, 50, 200, 100, 100, 50],
6565
'between upscale limit => return equals' =>
66-
[900, 400, 200, 100, 900, 400],
66+
[500, 200, 200, 100, 500, 200],
6767
'height over upscale limit => reduce to scale limit' =>
68-
[1200, 800, 200, 100, 750, 500],
68+
[800, 600, 200, 100, 400, 300],
6969
'width and height over upscale limit => reduce to scale limit' =>
70-
[2000, 1600, 200, 100, 625, 500],
70+
[2000, 1600, 200, 100, 375, 300],
7171
'every return integer' =>
72-
[2000, 1600, 200.7, 100.5, 628, 502],
72+
[2000, 1600, 200.7, 100.5, 376, 301],
7373
];
7474
}
7575
}

0 commit comments

Comments
 (0)