‪TYPO3CMS  10.4
SvgImageProcessor.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 
26 {
27  public function ‪canProcessTask(‪TaskInterface $task): bool
28  {
29  return $task->‪getType() === 'Image'
30  && in_array($task->‪getName(), ['Preview', 'CropScaleMask'], true)
31  && empty($task->‪getConfiguration()['crop'])
32  && $task->‪getTargetFileExtension() === 'svg';
33  }
34 
41  public function ‪processTask(‪TaskInterface $task): void
42  {
43  $task->‪setExecuted(true);
45  try {
46  $imageDimension = ‪ImageDimension::fromProcessingTask($task);
47  } catch (\Throwable $e) {
48  // To not fail image processing, we just assume an SVG image dimension here
49  $imageDimension = new ‪ImageDimension(64, 64);
50  }
52  [
53  'width' => $imageDimension->getWidth(),
54  'height' => $imageDimension->getHeight(),
55  'size' => $task->‪getSourceFile()->‪getSize(),
56  'checksum' => $task->‪getConfigurationChecksum()
57  ]
58  );
59  }
60 }
‪TYPO3\CMS\Core\Resource\Processing\TaskInterface\getType
‪string getType()
‪TYPO3\CMS\Core\Resource\Processing\TaskInterface
Definition: TaskInterface.php:33
‪TYPO3\CMS\Core\Resource\Processing\SvgImageProcessor
Definition: SvgImageProcessor.php:26
‪TYPO3\CMS\Core\Resource\Processing\TaskInterface\getSourceFile
‪Resource File getSourceFile()
‪TYPO3\CMS\Core\Resource\Processing\SvgImageProcessor\canProcessTask
‪canProcessTask(TaskInterface $task)
Definition: SvgImageProcessor.php:27
‪TYPO3\CMS\Core\Resource\ProcessedFile\setUsesOriginalFile
‪setUsesOriginalFile()
Definition: ProcessedFile.php:419
‪TYPO3\CMS\Core\Resource\Processing
Definition: AbstractGraphicalTask.php:16
‪TYPO3\CMS\Core\Imaging\ImageDimension\fromProcessingTask
‪static fromProcessingTask(TaskInterface $task)
Definition: ImageDimension.php:56
‪TYPO3\CMS\Core\Resource\Processing\SvgImageProcessor\processTask
‪processTask(TaskInterface $task)
Definition: SvgImageProcessor.php:41
‪TYPO3\CMS\Core\Resource\Processing\TaskInterface\getTargetFile
‪Resource ProcessedFile getTargetFile()
‪TYPO3\CMS\Core\Resource\Processing\TaskInterface\getName
‪string getName()
‪TYPO3\CMS\Core\Resource\Processing\TaskInterface\getConfiguration
‪array getConfiguration()
‪TYPO3\CMS\Core\Resource\AbstractFile\getSize
‪int null getSize()
Definition: AbstractFile.php:184
‪TYPO3\CMS\Core\Resource\ProcessedFile\updateProperties
‪updateProperties(array $properties)
Definition: ProcessedFile.php:345
‪TYPO3\CMS\Core\Resource\Processing\ProcessorInterface
Definition: ProcessorInterface.php:22
‪TYPO3\CMS\Core\Resource\Processing\TaskInterface\setExecuted
‪setExecuted($successful)
‪TYPO3\CMS\Core\Resource\Processing\TaskInterface\getConfigurationChecksum
‪string getConfigurationChecksum()
‪TYPO3\CMS\Core\Resource\Processing\TaskInterface\getTargetFileExtension
‪string getTargetFileExtension()
‪TYPO3\CMS\Core\Imaging\ImageDimension
Definition: ImageDimension.php:31