[BUGFIX] Apply quality settings for images 64/60464/3
authorBenni Mack <benni@typo3.org>
Sat, 13 Apr 2019 06:25:10 +0000 (08:25 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Mon, 15 Apr 2019 13:09:37 +0000 (15:09 +0200)
When combining or scaling images, the quality
setting needs to be applied as well.

Resolves: #31664
Releases: master, 9.5
Change-Id: Iab4d7247c1ee51483b9ede705f6c61ba11f37589
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60464
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
typo3/sysext/install/Classes/Controller/EnvironmentController.php

index 36adf70..d6b4039 100644 (file)
@@ -2481,7 +2481,9 @@ class GraphicalFunctions
         // +matte = no alpha layer in output
         $this->imageMagickExec($mask, $theMask, '-colorspace GRAY +matte');
 
-        $parameters = '-compose over +matte '
+        $parameters = '-compose over'
+            . ' -quality ' . $this->jpegQuality
+            . ' +matte '
             . CommandUtility::escapeShellArgument($input) . ' '
             . CommandUtility::escapeShellArgument($overlay) . ' '
             . CommandUtility::escapeShellArgument($theMask) . ' '
index a27f380..f147fb7 100644 (file)
@@ -29,6 +29,7 @@ use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
 use TYPO3\CMS\Core\Utility\CommandUtility;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Install\FolderStructure\DefaultFactory;
 use TYPO3\CMS\Install\FolderStructure\DefaultPermissionsCheck;
@@ -525,7 +526,8 @@ class EnvironmentController extends AbstractController
         $imageProcessor = $this->initializeImageProcessor();
         $inputFile = $imageBasePath . 'TestInput/Transparent.gif';
         $imageProcessor->imageMagickConvert_forceFileNameBody = StringUtility::getUniqueId('scale-jpg');
-        $imResult = $imageProcessor->imageMagickConvert($inputFile, 'jpg', '300', '', '-opaque white -background white -flatten', '', [], true);
+        $jpegQuality = MathUtility::forceIntegerInRange($GLOBALS['TYPO3_CONF_VARS']['GFX']['jpg_quality'], 10, 100, 85);
+        $imResult = $imageProcessor->imageMagickConvert($inputFile, 'jpg', '300', '', '-quality ' . $jpegQuality . ' -opaque white -background white -flatten', '', [], true);
         if ($imResult !== null && file_exists($imResult[3])) {
             $result = [
                 'fileExists' => true,