Skip to content

Commit

Permalink
[BUGFIX] Apply quality settings for images
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bmack authored and georgringer committed Apr 15, 2019
1 parent 1b37fb7 commit 89a75c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
Expand Up @@ -2481,7 +2481,9 @@ public function combineExec($input, $overlay, $mask, $output)
// +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) . ' '
Expand Down
Expand Up @@ -29,6 +29,7 @@
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;
Expand Down Expand Up @@ -525,7 +526,8 @@ public function imageProcessingGifToJpgAction(): ResponseInterface
$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,
Expand Down

0 comments on commit 89a75c5

Please sign in to comment.