67 $gifBuilder = GeneralUtility::makeInstance(GifBuilder::class);
69 $configuration = $targetFile->getProcessingConfiguration();
72 if (empty($configuration[
'fileExtension'])) {
79 if (!empty($configuration[
'crop'])) {
82 $cropData = json_decode($configuration[
'crop']);
84 $crop = implode(
',', [(
int)$cropData->x, (
int)$cropData->y, (
int)$cropData->width, (
int)$cropData->height]);
86 $crop = $configuration[
'crop'];
89 list($offsetLeft, $offsetTop, $newWidth, $newHeight) = explode(
',', $crop, 4);
91 $backupPrefix = $gifBuilder->filenamePrefix;
92 $gifBuilder->filenamePrefix =
'crop_';
97 $result = $gifBuilder->imageMagickConvert(
99 $configuration[
'fileExtension'],
102 sprintf(
'-crop %dx%d+%d+%d +repage -quality %d', $newWidth, $newHeight, $offsetLeft, $offsetTop, $jpegQuality),
107 $gifBuilder->filenamePrefix = $backupPrefix;
109 if ($result !==
null) {
110 $originalFileName = $croppedImage = $result[3];
115 if (!(is_array($configuration[
'maskImages']) &&
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'processor_enabled'])) {
118 if ($croppedImage ===
null && $sourceFile->getExtension() ===
'svg') {
119 $newDimensions = $this->
getNewSvgDimensions($sourceFile, $configuration, $options, $gifBuilder);
121 0 => $newDimensions[
'width'],
122 1 => $newDimensions[
'height'],
128 $result = $gifBuilder->imageMagickConvert(
130 $configuration[
'fileExtension'],
131 $configuration[
'width'],
132 $configuration[
'height'],
133 $configuration[
'additionalParameters'],
134 $configuration[
'frame'],
141 $maskImage = $configuration[
'maskImages'][
'maskImage'];
142 $maskBackgroundImage = $configuration[
'maskImages'][
'backgroundImage'];
144 $temporaryExtension =
'png';
145 if (!
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'processor_allowTemporaryMasksAsPng']) {
147 $temporaryExtension = $gifBuilder->gifExtension;
149 $tempFileInfo = $gifBuilder->imageMagickConvert(
152 $configuration[
'width'],
153 $configuration[
'height'],
154 $configuration[
'additionalParameters'],
155 $configuration[
'frame'],
158 if (is_array($tempFileInfo)) {
159 $maskBottomImage = $configuration[
'maskImages'][
'maskBottomImage'];
161 $maskBottomImageMask = $configuration[
'maskImages'][
'maskBottomImageMask'];
163 $maskBottomImageMask =
null;
168 $command =
'-geometry ' . $tempFileInfo[0] .
'x' . $tempFileInfo[1] .
'!';
170 $tmpStr = $gifBuilder->randomName();
172 $tempScale[
'm_mask'] = $tmpStr .
'_mask.' . $temporaryExtension;
173 $gifBuilder->imageMagickExec($maskImage->getForLocalProcessing(
true), $tempScale[
'm_mask'], $command);
175 $tempScale[
'm_bgImg'] = $tmpStr .
'_bgImg.miff';
176 $gifBuilder->imageMagickExec($maskBackgroundImage->getForLocalProcessing(), $tempScale[
'm_bgImg'], $command);
179 $tempScale[
'm_bottomImg'] = $tmpStr .
'_bottomImg.' . $temporaryExtension;
180 $gifBuilder->imageMagickExec($maskBottomImage->getForLocalProcessing(), $tempScale[
'm_bottomImg'], $command);
181 $tempScale[
'm_bottomImg_mask'] = ($tmpStr .
'_bottomImg_mask.') . $temporaryExtension;
182 $gifBuilder->imageMagickExec($maskBottomImageMask->getForLocalProcessing(), $tempScale[
'm_bottomImg_mask'], $command);
185 $gifBuilder->combineExec($tempScale[
'm_bgImg'], $tempScale[
'm_bottomImg'], $tempScale[
'm_bottomImg_mask'], $tempScale[
'm_bgImg']);
188 $gifBuilder->combineExec($tempScale[
'm_bgImg'], $tempFileInfo[3], $tempScale[
'm_mask'], $temporaryFileName);
189 $tempFileInfo[3] = $temporaryFileName;
191 foreach ($tempScale as $tempFile) {
192 if (@is_file($tempFile)) {
197 $result = $tempFileInfo;
202 if ($result !==
null) {
203 if ($result[3] !== $originalFileName || $originalFileName === $croppedImage) {
205 'width' => $result[0],
206 'height' => $result[1],
207 'filePath' => $result[3],
216 if ($croppedImage && ($result ===
null || $croppedImage !== $result[
'filePath'])) {
217 GeneralUtility::unlink_tempfile($croppedImage);
235 $info = [$file->getProperty(
'width'), $file->getProperty(
'height')];
236 $data = $gifBuilder->
getImageScale($info, $configuration[
'width'], $configuration[
'height'], $options);
240 if (!$data[
'origW']) {
241 $data[
'origW'] = $data[0];
243 if (!$data[
'origH']) {
244 $data[
'origH'] = $data[1];
246 if ($data[0] > $data[
'origW']) {
247 $data[1] = (int)(($data[
'origW'] * $data[1]) / $data[0]);
248 $data[0] = $data[
'origW'];
250 $data[0] = (int)(($data[
'origH'] * $data[0]) / $data[1]);
251 $data[1] = $data[
'origH'];
269 $configuration = $processedFile->getProcessingConfiguration();
271 if ($configuration[
'useSample']) {
272 $gifBuilder->scalecmd =
'-sample';
275 if ($configuration[
'maxWidth']) {
276 $options[
'maxW'] = $configuration[
'maxWidth'];
278 if ($configuration[
'maxHeight']) {
279 $options[
'maxH'] = $configuration[
'maxHeight'];
281 if ($configuration[
'minWidth']) {
282 $options[
'minW'] = $configuration[
'minWidth'];
284 if ($configuration[
'minHeight']) {
285 $options[
'minH'] = $configuration[
'minHeight'];
288 $options[
'noScale'] = $configuration[
'noScale'];
303 $processedFileExtension =
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'gdlib_png'] ?
'png' :
'gif';
304 if (is_array($configuration[
'maskImages']) &&
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'processor_enabled'] && $task->
getSourceFile()->
getExtension() != $processedFileExtension) {
305 $targetFileExtension =
'jpg';
306 } elseif ($configuration[
'fileExtension']) {
307 $targetFileExtension = $configuration[
'fileExtension'];
323 if (isset($configuration[
'stripProfile'])) {
325 $configuration[
'stripProfile']
326 &&
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'processor_stripColorProfileCommand'] !==
''
328 $parameters =
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'processor_stripColorProfileCommand'] . $parameters;
330 $parameters .=
'###SkipStripProfile###';