render() public method

Render method
public render ( ) : string
return string
Exemplo n.º 1
0
 /**
  * @return string
  */
 public function render()
 {
     $path = GeneralUtility::getFileAbsFileName($this->arguments['path']);
     if (FALSE === file_exists($path)) {
         return NULL;
     }
     $density = $this->arguments['density'];
     $rotate = $this->arguments['rotate'];
     $page = intval($this->arguments['page']);
     $background = $this->arguments['background'];
     $forceOverwrite = (bool) $this->arguments['forceOverwrite'];
     $width = $this->arguments['width'];
     $height = $this->arguments['height'];
     $minWidth = $this->arguments['minWidth'];
     $minHeight = $this->arguments['minHeight'];
     $maxWidth = $this->arguments['maxWidth'];
     $maxHeight = $this->arguments['maxHeight'];
     $filename = basename($path);
     $pageArgument = $page > 0 ? $page - 1 : 0;
     $colorspace = TRUE === isset($GLOBALS['TYPO3_CONF_VARS']['GFX']['colorspace']) ? $GLOBALS['TYPO3_CONF_VARS']['GFX']['colorspace'] : 'RGB';
     $destination = GeneralUtility::getFileAbsFileName('typo3temp/vhs-pdf-' . $filename . '-page' . $page . '.png');
     if (FALSE === file_exists($destination) || TRUE === $forceOverwrite) {
         $arguments = '-colorspace ' . $colorspace;
         if (0 < intval($density)) {
             $arguments .= ' -density ' . $density;
         }
         if (0 !== intval($rotate)) {
             $arguments .= ' -rotate ' . $rotate;
         }
         $arguments .= ' "' . $path . '"[' . $pageArgument . ']';
         if (NULL !== $background) {
             $arguments .= ' -background "' . $background . '" -flatten';
         }
         $arguments .= ' "' . $destination . '"';
         $command = CommandUtility::imageMagickCommand('convert', $arguments);
         CommandUtility::exec($command);
     }
     $image = substr($destination, strlen(PATH_site));
     return parent::render($image, $width, $height, $minWidth, $minHeight, $maxWidth, $maxHeight);
 }