From a8e74253e114b6691cb4dd57960fa1fe204d2c9c Mon Sep 17 00:00:00 2001 From: twoldanski <66474451+twoldanski@users.noreply.github.com> Date: Fri, 26 Jul 2024 12:39:10 +0200 Subject: [PATCH] [BUGFIX] Better normalize processing instructions (#756) - fix performance regression --- Classes/Utility/FileUtility.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Classes/Utility/FileUtility.php b/Classes/Utility/FileUtility.php index 144a0321..b7a9bdf0 100644 --- a/Classes/Utility/FileUtility.php +++ b/Classes/Utility/FileUtility.php @@ -294,16 +294,21 @@ public function processImageFile( $cropVariantCollection = $this->createCropVariant((string)$fileReference->getProperty('crop')); $cropArea = $cropVariantCollection->getCropArea($processingConfiguration->cropVariant); - return $this->imageService->applyProcessingInstructions($fileReference, [ - 'width' => $processingConfiguration->width, - 'height' => $processingConfiguration->height, - 'minWidth' => $processingConfiguration->minWidth, - 'minHeight' => $processingConfiguration->minHeight, - 'maxWidth' => $processingConfiguration->maxWidth, - 'maxHeight' => $processingConfiguration->maxWidth, + $instructions = [ + 'width' => $processingConfiguration->width !== '' ? $processingConfiguration->width : null, + 'height' => $processingConfiguration->height !== '' ? $processingConfiguration->height : null , + 'minWidth' => $processingConfiguration->minWidth > 0 ? $processingConfiguration->minWidth : null, + 'minHeight' => $processingConfiguration->minHeight > 0 ? $processingConfiguration->minHeight : null, + 'maxWidth' => $processingConfiguration->maxWidth > 0 ? $processingConfiguration->maxWidth : null, + 'maxHeight' => $processingConfiguration->maxHeight > 0 ? $processingConfiguration->maxHeight : null, 'crop' => $cropArea->isEmpty() ? null : $cropArea->makeAbsoluteBasedOnFile($fileReference), - 'fileExtension' => $processingConfiguration->fileExtension, - ]); + ]; + + if ($processingConfiguration->fileExtension) { + $instructions['fileExtension'] = $processingConfiguration->fileExtension; + } + + return $this->imageService->applyProcessingInstructions($fileReference, $instructions); } catch (\UnexpectedValueException|\RuntimeException|\InvalidArgumentException $e) { $type = lcfirst(get_class($fileReference)); $status = get_class($e);