本文整理汇总了PHP中TYPO3\CMS\Core\Utility\CommandUtility::imageMagickCommand方法的典型用法代码示例。如果您正苦于以下问题:PHP CommandUtility::imageMagickCommand方法的具体用法?PHP CommandUtility::imageMagickCommand怎么用?PHP CommandUtility::imageMagickCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\CommandUtility
的用法示例。
在下文中一共展示了CommandUtility::imageMagickCommand方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* @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);
}
示例2: render
/**
* @return string
*/
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();
}
示例3: imageMagickCommand
/**
* Compile the command for running ImageMagick/GraphicsMagick.
*
* @param string $command Command to be run: identify, convert or combine/composite
* @param string $parameters The parameters string
* @param string $path Override the default path (e.g. used by the install tool)
* @return string Compiled command that deals with IM6 & GraphicsMagick
*/
public static function imageMagickCommand($command, $parameters, $path = '')
{
return \TYPO3\CMS\Core\Utility\CommandUtility::imageMagickCommand($command, $parameters, $path);
}
示例4: determineImageMagickVersion
/**
* Determine ImageMagick / GraphicsMagick version
*
* @return string Version
*/
protected function determineImageMagickVersion()
{
$command = \TYPO3\CMS\Core\Utility\CommandUtility::imageMagickCommand('identify', '-version');
\TYPO3\CMS\Core\Utility\CommandUtility::exec($command, $result);
$string = $result[0];
list(, $version) = explode('Magick', $string);
list($version) = explode(' ', trim($version));
return trim($version);
}
示例5: imageMagickCommand
/**
* Compile the command for running ImageMagick/GraphicsMagick.
*
* @param string $command Command to be run: identify, convert or combine/composite
* @param string $parameters The parameters string
* @param string $path Override the default path (e.g. used by the install tool)
* @return string Compiled command that deals with IM6 & GraphicsMagick
*/
public static function imageMagickCommand($command, $parameters, $path = '')
{
return CommandUtility::imageMagickCommand($command, $parameters, $path);
}
示例6: readPngGif
/**
* Returns filename of the png/gif version of the input file (which can be png or gif).
* If input file type does not match the wanted output type a conversion is made and temp-filename returned.
*
* @param string $theFile Filepath of image file
* @param bool $output_png If TRUE, then input file is converted to PNG, otherwise to GIF
* @return string|NULL If the new image file exists, its filepath is returned
*/
public static function readPngGif($theFile, $output_png = false)
{
if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_enabled'] || !@is_file($theFile)) {
return null;
}
$ext = strtolower(substr($theFile, -4, 4));
if ((string) $ext == '.png' && $output_png || (string) $ext == '.gif' && !$output_png) {
return $theFile;
}
if (!@is_dir(PATH_site . 'typo3temp/assets/images/')) {
GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/assets/images/');
}
$newFile = PATH_site . 'typo3temp/assets/images/' . md5($theFile . '|' . filemtime($theFile)) . ($output_png ? '.png' : '.gif');
$cmd = CommandUtility::imageMagickCommand('convert', '"' . $theFile . '" "' . $newFile . '"', $GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_path']);
CommandUtility::exec($cmd);
if (@is_file($newFile)) {
GeneralUtility::fixPermissions($newFile);
return $newFile;
}
return null;
}
示例7: generatePreviewFromFile
/**
* Generates a preview for a file
*
* @param File $file The source file
* @param array $configuration Processing configuration
* @param string $targetFilePath Output file path
* @return array|NULL
*/
protected function generatePreviewFromFile(File $file, array $configuration, $targetFilePath)
{
$originalFileName = $file->getForLocalProcessing(false);
// Check file extension
if ($file->getType() != File::FILETYPE_IMAGE && !GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $file->getExtension())) {
// Create a default image
$graphicalFunctions = GeneralUtility::makeInstance(GraphicalFunctions::class);
$graphicalFunctions->getTemporaryImageWithText($targetFilePath, 'Not imagefile!', 'No ext!', $file->getName());
$result = array('filePath' => $targetFilePath);
} elseif ($file->getExtension() === 'svg') {
/** @var $gifBuilder \TYPO3\CMS\Frontend\Imaging\GifBuilder */
$gifBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Imaging\GifBuilder::class);
$gifBuilder->init();
$gifBuilder->absPrefix = PATH_site;
$info = $gifBuilder->getImageDimensions($originalFileName);
$newInfo = $gifBuilder->getImageScale($info, $configuration['width'], $configuration['height'], array());
$result = array('width' => $newInfo[0], 'height' => $newInfo[1], 'filePath' => '');
} else {
// Create the temporary file
if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_enabled']) {
$parameters = '-sample ' . $configuration['width'] . 'x' . $configuration['height'] . ' ' . CommandUtility::escapeShellArgument($originalFileName) . '[0] ' . CommandUtility::escapeShellArgument($targetFilePath);
$cmd = CommandUtility::imageMagickCommand('convert', $parameters) . ' 2>&1';
CommandUtility::exec($cmd);
if (!file_exists($targetFilePath)) {
// Create an error gif
$graphicalFunctions = GeneralUtility::makeInstance(GraphicalFunctions::class);
$graphicalFunctions->getTemporaryImageWithText($targetFilePath, 'No thumb', 'generated!', $file->getName());
}
}
$result = array('filePath' => $targetFilePath);
}
return $result;
}