Skip to content

Commit

Permalink
[BUGFIX] Better normalize processing instructions (#756)
Browse files Browse the repository at this point in the history
- fix performance regression
  • Loading branch information
twoldanski committed Jul 26, 2024
1 parent cff669f commit a8e7425
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions Classes/Utility/FileUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a8e7425

Please sign in to comment.