‪TYPO3CMS  ‪main
ImageMagick6Preset.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 = 'ImageMagick6';
31 
35  protected ‪$priority = 70;
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' => 'ImageMagick',
45  'GFX/processor_effects' => true,
46  'GFX/processor_colorspace' => 'sRGB',
47  ];
48 
54  protected function ‪findExecutableInPath(array $searchPaths)
55  {
56  return $this->‪findImageMagick6InPaths($searchPaths);
57  }
58 
65  protected function ‪findImageMagick6InPaths(array $searchPaths)
66  {
67  $result = false;
68  foreach ($searchPaths as $path) {
70  $executable = 'identify.exe';
71 
72  if (!@is_file($path . $executable)) {
73  $executable = 'magick.exe';
74  }
75  } else {
76  $executable = 'identify';
77  }
78 
79  $binaryPath = $path . $executable;
80  if (!file_exists($binaryPath) || !is_executable($binaryPath)) {
81  continue;
82  }
83 
84  $command = escapeshellarg($binaryPath) . ' -version';
85  $executingResult = [];
86  ‪CommandUtility::exec($command, $executingResult);
87  // First line of exec command should contain string GraphicsMagick
88  $firstResultLine = array_shift($executingResult);
89  // Example: "Version: ImageMagick 6.6.0-4 2012-05-02 Q16 http://www.imagemagick.org"
90  if (is_string($firstResultLine) && str_contains($firstResultLine, 'ImageMagick')) {
91  [, $version] = explode('ImageMagick', $firstResultLine);
92  // Example: "6.6.0-4"
93  [$version] = explode(' ', trim($version));
94  if (version_compare($version, '6.0.0') >= 0) {
95  $this->foundPath = $path;
96  $result = true;
97  break;
98  }
99  }
100  }
101  return $result;
102  }
103 }
‪TYPO3\CMS\Install\Configuration\Image\ImageMagick6Preset\$configurationValues
‪array $configurationValues
Definition: ImageMagick6Preset.php:37
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset
Definition: AbstractImagePreset.php:26
‪TYPO3\CMS\Install\Configuration\Image\ImageMagick6Preset\findImageMagick6InPaths
‪bool findImageMagick6InPaths(array $searchPaths)
Definition: ImageMagick6Preset.php:62
‪TYPO3\CMS\Install\Configuration\Image\ImageMagick6Preset
Definition: ImageMagick6Preset.php:26
‪TYPO3\CMS\Install\Configuration\Image\ImageMagick6Preset\$priority
‪int $priority
Definition: ImageMagick6Preset.php:33
‪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\ImageMagick6Preset\findExecutableInPath
‪mixed findExecutableInPath(array $searchPaths)
Definition: ImageMagick6Preset.php:51
‪TYPO3\CMS\Install\Configuration\Image\ImageMagick6Preset\$name
‪string $name
Definition: ImageMagick6Preset.php:29
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:41
‪TYPO3\CMS\Core\Utility\CommandUtility
Definition: CommandUtility.php:54
‪TYPO3\CMS\Core\Core\Environment\isWindows
‪static isWindows()
Definition: Environment.php:276