From 5ccfc9a6f7664d662448d52bce19c703443a8c9a Mon Sep 17 00:00:00 2001 From: Benni Mack <benni@typo3.org> Date: Wed, 20 Sep 2023 21:17:42 +0200 Subject: [PATCH] [BUGFIX] Use "sample" instead of "useSample" in FAL processing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using TypoScript, the setting "sample" allows to scale faster than with "geometry" setting. However, when FAL was introduced the setting was called "useSample" which never worked since TYPO3 v6.0 in conjunction with FAL. The option is however useful and is now working again. The according code is moved into GraphicalFunctions in order to avoid future access to this public property. Resolves: #101981 Releases: main, 12.4 Change-Id: I5c926460d4c5393c418d1e90fcb11052ab3e5cae Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/81115 Tested-by: Stefan Bürk <stefan@buerk.tech> Tested-by: core-ci <typo3@b13.com> Reviewed-by: Oliver Bartsch <bo@cedev.de> Reviewed-by: Stefan Bürk <stefan@buerk.tech> Reviewed-by: Benni Mack <benni@typo3.org> Tested-by: Benni Mack <benni@typo3.org> Tested-by: Oliver Bartsch <bo@cedev.de> --- typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php | 8 ++++++-- .../Resource/Processing/LocalCropScaleMaskHelper.php | 6 +++--- .../Classes/ContentObject/ContentObjectRenderer.php | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php b/typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php index 958f8d479203..2356abdae98a 100644 --- a/typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php +++ b/typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php @@ -161,7 +161,7 @@ class GraphicalFunctions * * @var string */ - public $scalecmd = '-auto-orient -geometry'; + public $scalecmd = '-auto-orient'; /** * Used by v5_blur() to simulate 10 continuous steps of blurring @@ -367,7 +367,11 @@ class GraphicalFunctions $offsetY = (int)(($data[1] - $data['origH']) * ($data['cropV'] + 100) / 200); $params .= ' -crop ' . $data['origW'] . 'x' . $data['origH'] . '+' . $offsetX . '+' . $offsetY . '! +repage'; } - $command = $this->scalecmd . ' ' . $info[0] . 'x' . $info[1] . '! ' . $params . ' '; + // start with the default scale command + $command = $this->scalecmd; + // check if we should use -sample or -geometry + $command .= ' ' . (($options['sample'] ?? false) ? '-sample' : '-geometry'); + $command .= ' ' . $info[0] . 'x' . $info[1] . '! ' . $params . ' '; // re-apply colorspace-setting for the resulting image so colors don't appear to dark (sRGB instead of RGB) $command .= ' -colorspace ' . $this->colorspace; $cropscale = $data['crs'] ? 'crs-V' . $data['cropV'] . 'H' . $data['cropH'] : ''; diff --git a/typo3/sysext/core/Classes/Resource/Processing/LocalCropScaleMaskHelper.php b/typo3/sysext/core/Classes/Resource/Processing/LocalCropScaleMaskHelper.php index 6c38ba7099ef..43c5dda78d95 100644 --- a/typo3/sysext/core/Classes/Resource/Processing/LocalCropScaleMaskHelper.php +++ b/typo3/sysext/core/Classes/Resource/Processing/LocalCropScaleMaskHelper.php @@ -209,10 +209,10 @@ class LocalCropScaleMaskHelper { $configuration = $processedFile->getProcessingConfiguration(); - if ($configuration['useSample'] ?? false) { - $imageOperations->scalecmd = '-sample'; - } $options = []; + if ($configuration['sample'] ?? false) { + $options['sample'] = true; + } if ($configuration['maxWidth'] ?? false) { $options['maxW'] = $configuration['maxWidth']; } diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php index 38fc7c51d0cd..39174dcc4492 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php +++ b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php @@ -3711,6 +3711,7 @@ class ContentObjectRenderer implements LoggerAwareInterface $processingConfiguration['minWidth'] = (int)$this->stdWrapValue('minW', $fileArray ?? []); $processingConfiguration['minHeight'] = (int)$this->stdWrapValue('minH', $fileArray ?? []); $processingConfiguration['noScale'] = $this->stdWrapValue('noScale', $fileArray ?? []); + $processingConfiguration['sample'] = (bool)$this->stdWrapValue('sample', $fileArray); $processingConfiguration['additionalParameters'] = $this->stdWrapValue('params', $fileArray ?? []); $processingConfiguration['frame'] = (int)$this->stdWrapValue('frame', $fileArray ?? []); if ($fileReference instanceof FileReference) { -- GitLab