Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions Classes/Resource/Processing/DeferredImageProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ public function canProcessTask(TaskInterface $task): bool
{
return $task->getType() === 'Image'
&& $task->getName() === 'CropScaleMask'
&& (
str_starts_with($task->getSourceFile()->getMimeType(), 'image/')
|| $task->getSourceFile()->getMimeType() === 'application/pdf'
)
&& $task->getSourceFile()->getMimeType() !== 'image/svg+xml'
&& $task->getSourceFile()->getExtension() !== 'svg'
&& $task->getSourceFile()->getMimeType() !== 'application/pdf'
&& $task->getSourceFile()->getExtension() !== 'pdf';
&& $task->getSourceFile()->getExtension() !== 'svg';
}

public function processTask(TaskInterface $task): void
Expand All @@ -35,15 +37,17 @@ public function processTask(TaskInterface $task): void
$task->setExecuted($localTask->isSuccessful());
}
} else {
if (!$this->canProcessTask($task)) {
throw new \InvalidArgumentException('Cannot process task of type "' . $task->getType() . '.' . $task->getName() . '"', 1350570621);
}
if ($this->checkForExistingTargetFile($task)) {
return;
}

$imageDimensions = ImageDimension::fromProcessingTask($task);
if ($imageDimensions->getWidth() === $task->getTargetFile()->getOriginalFile()->getProperty('width') && $imageDimensions->getHeight() === $task->getTargetFile()->getOriginalFile()->getProperty('height') && !$task->getConfiguration()['crop']) {
if (
$imageDimensions->getWidth() === $task->getTargetFile()->getOriginalFile()->getProperty('width')
&& $imageDimensions->getHeight() === $task->getTargetFile()->getOriginalFile()->getProperty('height')
&& !$task->getConfiguration()['crop']
&& $task->getSourceFile()->getMimeType() !== 'application/pdf'
) {
// If the target image dimensions are identical to the original file and no cropping is defined, do not process, but use the original file
$task->setExecuted(true);
$task->getTargetFile()->setUsesOriginalFile();
Expand Down