‪TYPO3CMS  ‪main
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 is determined and set by path lookup methods
43  'GFX/processor_path' => '',
44  'GFX/processor' => 'GraphicsMagick',
45  'GFX/processor_effects' => false,
46  ];
47 
53  protected function ‪findExecutableInPath(array $searchPaths)
54  {
55  return $this->‪findGraphicsMagickInPaths($searchPaths);
56  }
57 
64  protected function ‪findGraphicsMagickInPaths(array $searchPaths)
65  {
66  $result = false;
67  foreach ($searchPaths as $path) {
69  $executable = 'gm.exe';
70  } else {
71  $executable = 'gm';
72  }
73 
74  $binaryPath = $path . $executable;
75  if (!file_exists($binaryPath) || !is_executable($binaryPath)) {
76  continue;
77  }
78 
79  $command = escapeshellarg($binaryPath) . ' -version';
80  $executingResult = [];
81  @‪CommandUtility::exec($command, $executingResult);
82  // First line of exec command should contain string GraphicsMagick
83  $firstResultLine = array_shift($executingResult);
84  if (is_string($firstResultLine) && str_contains($firstResultLine, 'GraphicsMagick')) {
85  $this->foundPath = $path;
86  $result = true;
87  break;
88  }
89  }
90 
91  return $result;
92  }
93 }
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset
Definition: AbstractImagePreset.php:26
‪TYPO3\CMS\Install\Configuration\Image\GraphicsMagickPreset\$name
‪string $name
Definition: GraphicsMagickPreset.php:29
‪TYPO3\CMS\Install\Configuration\Image\GraphicsMagickPreset\findExecutableInPath
‪mixed findExecutableInPath(array $searchPaths)
Definition: GraphicsMagickPreset.php:50
‪TYPO3\CMS\Install\Configuration\Image\GraphicsMagickPreset\$configurationValues
‪array $configurationValues
Definition: GraphicsMagickPreset.php:37
‪TYPO3\CMS\Install\Configuration\Image\GraphicsMagickPreset
Definition: GraphicsMagickPreset.php:26
‪TYPO3\CMS\Core\Utility\CommandUtility\exec
‪static exec(string $command, ?array &$output=null, int &$returnValue=0)
Definition: CommandUtility.php:85
‪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:41
‪TYPO3\CMS\Core\Utility\CommandUtility
Definition: CommandUtility.php:54
‪TYPO3\CMS\Install\Configuration\Image\GraphicsMagickPreset\findGraphicsMagickInPaths
‪bool findGraphicsMagickInPaths(array $searchPaths)
Definition: GraphicsMagickPreset.php:61
‪TYPO3\CMS\Core\Core\Environment\isWindows
‪static isWindows()
Definition: Environment.php:276