public function render()
{
$src = GeneralUtility::getFileAbsFileName($this->arguments['src']);
if (false === file_exists($src)) {
return null;
}
$density = $this->arguments['density'];
$rotate = $this->arguments['rotate'];
$page = (int) $this->arguments['page'];
$background = $this->arguments['background'];
$forceOverwrite = (bool) $this->arguments['forceOverwrite'];
$filename = basename($src);
$pageArgument = $page > 0 ? $page - 1 : 0;
if (isset($GLOBALS['TYPO3_CONF_VARS']['GFX']['colorspace'])) {
$colorspace = $GLOBALS['TYPO3_CONF_VARS']['GFX']['colorspace'];
} else {
$colorspace = 'RGB';
}
$path = GeneralUtility::getFileAbsFileName('typo3temp/vhs-pdf-' . $filename . '-page' . $page . '.png');
if (false === file_exists($path) || true === $forceOverwrite) {
$arguments = '-colorspace ' . $colorspace;
if (0 < (int) $density) {
$arguments .= ' -density ' . $density;
}
if (0 !== (int) $rotate) {
$arguments .= ' -rotate ' . $rotate;
}
$arguments .= ' "' . $src . '"[' . $pageArgument . ']';
if (null !== $background) {
$arguments .= ' -background "' . $background . '" -flatten';
}
$arguments .= ' "' . $path . '"';
$command = CommandUtility::imageMagickCommand('convert', $arguments);
CommandUtility::exec($command);
}
$this->preprocessImage($path);
return $this->renderTag();
}