Skip to content

Commit

Permalink
[BUGFIX] Respect GFX/jpg_quality when cropping
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
brandung-gs authored and lolli42 committed May 10, 2018
1 parent 9106cf7 commit 669018c
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use TYPO3\CMS\Core\Resource;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Frontend\Imaging\GifBuilder;

/**
Expand Down Expand Up @@ -91,13 +92,15 @@ public function process(TaskInterface $task)
$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
Expand Down

1 comment on commit 669018c

@YetiCGN
Copy link
Contributor

@YetiCGN YetiCGN commented on 669018c Mar 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any possibility this could be backported to TYPO3 CMS 8.7 LTS? I stumbled upon this bug yesterday but we can't upgrade to 9.5 LTS yet.

Please sign in to comment.