2 namespace TYPO3\CMS\Core\Resource\OnlineMedia\Processing;
46 return $processedFile->isNew()
47 || (!$processedFile->usesOriginalFile() && !$processedFile->exists())
48 || $processedFile->isOutdated();
64 if ($taskType !==
'Image.Preview' && $taskType !==
'Image.CropScaleMask') {
73 if ($helper ===
false) {
77 $temporaryFileName = $helper->getPreviewImage($file);
78 if (empty($temporaryFileName) || !file_exists($temporaryFileName)) {
81 $temporaryFileNameForResizedThumb = uniqid(PATH_site .
'typo3temp/online_media_' . $file->
getHashedIdentifier()) .
'.jpg';
85 $configuration = array_merge(array(
'width' => 64,
'height' => 64), $configuration);
88 $this->
resizeImage($temporaryFileName, $temporaryFileNameForResizedThumb, $configuration);
91 case 'Image.CropScaleMask':
92 $this->cropScaleImage($temporaryFileName, $temporaryFileNameForResizedThumb, $configuration);
95 if (is_file($temporaryFileNameForResizedThumb)) {
97 list($width, $height) = getimagesize($temporaryFileNameForResizedThumb);
102 'size' => filesize($temporaryFileNameForResizedThumb),
103 'checksum' => $processedFile->
getTask()->getConfigurationChecksum()
110 $processedFileRepository->add($processedFile);
121 return $prefix . $processedFile->
getTask()->getConfigurationChecksum() .
'_' . $processedFile->
getOriginalFile()->getNameWithoutExtension() .
'.jpg';
129 protected function resizeImage($originalFileName, $temporaryFileName, $configuration)
132 if (empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'im'])) {
136 if (file_exists($originalFileName)) {
138 'width' => $configuration[
'width'],
139 'height' => $configuration[
'height'],
140 'originalFileName' => $originalFileName,
141 'temporaryFileName' => $temporaryFileName,
143 $parameters =
'-sample ' . $arguments[
'width'] .
'x' . $arguments[
'height'] .
' '
144 . $arguments[
'originalFileName'] .
'[0] ' . $arguments[
'temporaryFileName'];
150 if (!file_exists($temporaryFileName)) {
153 $graphicalFunctions->getTemporaryImageWithText($temporaryFileName,
'No thumb',
'generated!', basename($originalFileName));
164 protected function cropScaleImage($originalFileName, $temporaryFileName, $configuration)
166 if (file_exists($originalFileName)) {
172 $info = $gifBuilder->getImageDimensions($originalFileName);
173 $data = $gifBuilder->getImageScale($info, $configuration[
'width'], $configuration[
'height'], $options);
178 $params = $gifBuilder->cmds[
'jpg'];
182 if (!$data[
'origW']) {
183 $data[
'origW'] = $data[0];
185 if (!$data[
'origH']) {
186 $data[
'origH'] = $data[1];
188 $offsetX = (int)(($data[0] - $data[
'origW']) * ($data[
'cropH'] + 100) / 200);
189 $offsetY = (int)(($data[1] - $data[
'origH']) * ($data[
'cropV'] + 100) / 200);
190 $params .=
' -crop ' . $data[
'origW'] .
'x' . $data[
'origH'] .
'+' . $offsetX .
'+' . $offsetY .
'! ';
192 $command = $gifBuilder->scalecmd .
' ' . $info[0] .
'x' . $info[1] .
'! ' . $params .
' ';
193 $gifBuilder->imageMagickExec($originalFileName, $temporaryFileName, $command, $frame);
195 if (!file_exists($temporaryFileName)) {
198 $graphicalFunctions->getTemporaryImageWithText($temporaryFileName,
'No thumb',
'generated!', basename($originalFileName));
211 if (!empty($configuration[
'useSample'])) {
212 $gifBuilder->scalecmd =
'-sample';
215 if (!empty($configuration[
'maxWidth'])) {
216 $options[
'maxW'] = $configuration[
'maxWidth'];
218 if (!empty($configuration[
'maxHeight'])) {
219 $options[
'maxH'] = $configuration[
'maxHeight'];
221 if (!empty($configuration[
'minWidth'])) {
222 $options[
'minW'] = $configuration[
'minWidth'];
224 if (!empty($configuration[
'minHeight'])) {
225 $options[
'minH'] = $configuration[
'minHeight'];
228 $options[
'noScale'] = $configuration[
'noScale'];
238 if (!$this->processor) {
249 static $graphicalFunctionsObject = null;
250 if ($graphicalFunctionsObject === null) {
253 return $graphicalFunctionsObject;