‪TYPO3CMS  10.4
GraphicsMagickPreset.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
20 
26 {
30  protected ‪$name = 'GraphicsMagick';
31 
35  protected ‪$priority = 80;
36 
40  protected ‪$configurationValues = [
41  'GFX/processor_enabled' => true,
42  // processor_path and processor_path_lzw are determined and set by path lookup methods
43  'GFX/processor_path' => '',
44  'GFX/processor_path_lzw' => '',
45  'GFX/processor' => 'GraphicsMagick',
46  'GFX/processor_effects' => false,
47  'GFX/processor_allowTemporaryMasksAsPng' => false,
48  'GFX/processor_colorspace' => 'RGB',
49  ];
50 
57  protected function ‪findExecutableInPath(array $searchPaths)
58  {
59  return $this->‪findGraphicsMagickInPaths($searchPaths);
60  }
61 
68  protected function ‪findGraphicsMagickInPaths(array $searchPaths)
69  {
70  $result = false;
71  foreach ($searchPaths as $path) {
73  $executable = 'gm.exe';
74  } else {
75  $executable = 'gm';
76  }
77  if (@is_file($path . $executable)) {
78  $command = escapeshellarg($path . $executable) . ' -version';
79  $executingResult = false;
80  ‪CommandUtility::exec($command, $executingResult);
81  // First line of exec command should contain string GraphicsMagick
82  $firstResultLine = array_shift($executingResult);
83  if (strpos($firstResultLine, 'GraphicsMagick') !== false) {
84  $this->foundPath = $path;
85  $result = true;
86  break;
87  }
88  }
89  }
90  return $result;
91  }
92 }
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset
Definition: AbstractImagePreset.php:27
‪TYPO3\CMS\Install\Configuration\Image\GraphicsMagickPreset\$name
‪string $name
Definition: GraphicsMagickPreset.php:29
‪TYPO3\CMS\Core\Core\Environment\isWindows
‪static bool isWindows()
Definition: Environment.php:292
‪TYPO3\CMS\Install\Configuration\Image\GraphicsMagickPreset\findExecutableInPath
‪mixed findExecutableInPath(array $searchPaths)
Definition: GraphicsMagickPreset.php:54
‪TYPO3\CMS\Install\Configuration\Image\GraphicsMagickPreset\$configurationValues
‪array $configurationValues
Definition: GraphicsMagickPreset.php:37
‪TYPO3\CMS\Core\Utility\CommandUtility\exec
‪static string exec($command, &$output=null, &$returnValue=0)
Definition: CommandUtility.php:81
‪TYPO3\CMS\Install\Configuration\Image\GraphicsMagickPreset
Definition: GraphicsMagickPreset.php:26
‪TYPO3\CMS\Install\Configuration\Image
Definition: AbstractImagePreset.php:16
‪TYPO3\CMS\Install\Configuration\Image\GraphicsMagickPreset\$priority
‪int $priority
Definition: GraphicsMagickPreset.php:33
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:40
‪TYPO3\CMS\Core\Utility\CommandUtility
Definition: CommandUtility.php:49
‪TYPO3\CMS\Install\Configuration\Image\GraphicsMagickPreset\findGraphicsMagickInPaths
‪bool findGraphicsMagickInPaths(array $searchPaths)
Definition: GraphicsMagickPreset.php:65