/** * @throws Exception * @return void */ public function preprocessImage() { $src = $this->arguments['src']; $width = $this->arguments['width']; $height = $this->arguments['height']; $minW = $this->arguments['minW']; $minH = $this->arguments['minH']; $maxW = $this->arguments['maxW']; $maxH = $this->arguments['maxH']; $format = $this->arguments['format']; $quality = $this->arguments['quality']; $treatIdAsReference = (bool) $this->arguments['treatIdAsReference']; if ('BE' === TYPO3_MODE) { $this->simulateFrontendEnvironment(); } $setup = array('width' => $width, 'height' => $height, 'minW' => $minW, 'minH' => $minH, 'maxW' => $maxW, 'maxH' => $maxH, 'treatIdAsReference' => $treatIdAsReference); if (FALSE === empty($format)) { $setup['ext'] = $format; } if (0 < intval($quality)) { $quality = MathUtility::forceIntegerInRange($quality, 10, 100, 75); $setup['params'] = '-quality ' . $quality; } if ('BE' === TYPO3_MODE && '../' === substr($src, 0, 3)) { $src = substr($src, 3); } $this->imageInfo = $this->contentObject->getImgResource($src, $setup); $GLOBALS['TSFE']->lastImageInfo = $this->imageInfo; if (FALSE === is_array($this->imageInfo)) { throw new Exception('Could not get image resource for "' . htmlspecialchars($src) . '".', 1253191060); } if ((double) substr(TYPO3_version, 0, 3) < 7.1) { $this->imageInfo[3] = GeneralUtility::png_to_gif_by_imagemagick($this->imageInfo[3]); } else { $this->imageInfo[3] = GraphicalFunctions::pngToGifByImagemagick($this->imageInfo[3]); } $GLOBALS['TSFE']->imagesOnPage[] = $this->imageInfo[3]; $publicUrl = rawurldecode($this->imageInfo[3]); $this->mediaSource = $GLOBALS['TSFE']->absRefPrefix . GeneralUtility::rawUrlEncodeFP($publicUrl); if ('BE' === TYPO3_MODE) { $this->resetFrontendEnvironment(); } }
/** * Converts a png file to gif. * This converts a png file to gif IF the FLAG $GLOBALS['TYPO3_CONF_VARS']['FE']['png_to_gif'] is set TRUE. * * @param string $theFile The filename with path * @return string New filename * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8. Use \TYPO3\CMS\Core\Imaging\GraphicalFunctions::pngToGifByImagemagick() instead. */ public static function png_to_gif_by_imagemagick($theFile) { static::logDeprecatedFunction(); $newFile = GraphicalFunctions::pngToGifByImagemagick($theFile); return $newFile; }
/** * @param array $files * @param boolean $onlyProperties * @throws Exception * @return array|NULL */ public function preprocessImages($files, $onlyProperties = FALSE) { if (TRUE === empty($files)) { return NULL; } if ('BE' === TYPO3_MODE) { $this->simulateFrontendEnvironment(); } $setup = array('width' => $this->arguments['width'], 'height' => $this->arguments['height'], 'minW' => $this->arguments['minWidth'], 'minH' => $this->arguments['minHeight'], 'maxW' => $this->arguments['maxWidth'], 'maxH' => $this->arguments['maxHeight'], 'treatIdAsReference' => FALSE); $images = array(); foreach ($files as $file) { $imageInfo = $this->contentObject->getImgResource($file->getUid(), $setup); $GLOBALS['TSFE']->lastImageInfo = $imageInfo; if (FALSE === is_array($imageInfo)) { throw new Exception('Could not get image resource for "' . htmlspecialchars($file->getCombinedIdentifier()) . '".', 1253191060); } if ((double) substr(TYPO3_version, 0, 3) < 7.1) { $imageInfo[3] = GeneralUtility::png_to_gif_by_imagemagick($imageInfo[3]); } else { $imageInfo[3] = GraphicalFunctions::pngToGifByImagemagick($imageInfo[3]); } $imageInfo[3] = GeneralUtility::png_to_gif_by_imagemagick($imageInfo[3]); $GLOBALS['TSFE']->imagesOnPage[] = $imageInfo[3]; if (TRUE === GeneralUtility::isValidUrl($imageInfo[3])) { $imageSource = $imageInfo[3]; } else { $imageSource = $GLOBALS['TSFE']->absRefPrefix . GeneralUtility::rawUrlEncodeFP($imageInfo[3]); } if (TRUE === $onlyProperties) { $file = ResourceUtility::getFileArray($file); } $images[] = array('info' => $imageInfo, 'source' => $imageSource, 'file' => $file); } if ('BE' === TYPO3_MODE) { $this->resetFrontendEnvironment(); } return $images; }