[BUGFIX] Respect GFX/jpg_quality when cropping 79/56779/4
authorGuido Schmechel <guido.schmechel@brandung.de>
Sat, 21 Apr 2018 21:50:11 +0000 (23:50 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 10 May 2018 19:37:35 +0000 (21:37 +0200)
LocalCropScaleMaskHelper generates thumbnails with
imageMagickConvert and custom crop parameters. This
will overwrite the default settings.

Append the GFX/jpg_quality parameter to the convert command.

Resolves: #81796
Releases: master
Change-Id: Iaa09e8b9134659c9ffba1c2984ef06d2c8250580
Reviewed-on: https://review.typo3.org/56779
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: Bernhard Kraft <kraftb@think-open.at>
Reviewed-by: Alessandro <alessandro.filira@pallino.it>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/Resource/Processing/LocalCropScaleMaskHelper.php

index 6403b8a..f3ec484 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Core\Resource\Processing;
 
 use TYPO3\CMS\Core\Resource;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Frontend\Imaging\GifBuilder;
 
 /**
@@ -91,13 +92,15 @@ class LocalCropScaleMaskHelper
             $backupPrefix = $gifBuilder->filenamePrefix;
             $gifBuilder->filenamePrefix = 'crop_';
 
+            $jpegQuality = MathUtility::forceIntegerInRange($GLOBALS['TYPO3_CONF_VARS']['GFX']['jpg_quality'], 10, 100, 85);
+
             // the result info is an array with 0=width,1=height,2=extension,3=filename
             $result = $gifBuilder->imageMagickConvert(
                 $originalFileName,
                 $configuration['fileExtension'],
                 '',
                 '',
-                sprintf('-crop %dx%d+%d+%d +repage', $newWidth, $newHeight, $offsetLeft, $offsetTop),
+                sprintf('-crop %dx%d+%d+%d +repage -quality %d', $newWidth, $newHeight, $offsetLeft, $offsetTop, $jpegQuality),
                 '',
                 ['noScale' => true],
                 true