TYPO3 CMS  TYPO3_8-7
ImageMagick6Preset.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
18 
23 {
27  protected $name = 'ImageMagick6';
28 
32  protected $priority = 70;
33 
37  protected $configurationValues = [
38  'GFX/processor_enabled' => true,
39  // processor_path and processor_path_lzw are determined and set by path lookup methods
40  'GFX/processor_path' => '',
41  'GFX/processor_path_lzw' => '',
42  'GFX/processor' => 'ImageMagick',
43  'GFX/processor_effects' => 1,
44  'GFX/processor_allowTemporaryMasksAsPng' => false,
45  'GFX/processor_colorspace' => 'sRGB',
46  ];
47 
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) {
69  if (TYPO3_OS === 'WIN') {
70  $executable = 'identify.exe';
71 
72  if (!@is_file($path . $executable)) {
73  $executable = 'magick.exe';
74  }
75  } else {
76  $executable = 'identify';
77  }
78  if (@is_file($path . $executable)) {
79  $command = escapeshellarg($path . $executable) . ' -version';
80  $executingResult = false;
81  \TYPO3\CMS\Core\Utility\CommandUtility::exec($command, $executingResult);
82  // First line of exec command should contain string GraphicsMagick
83  $firstResultLine = array_shift($executingResult);
84  // Example: "Version: ImageMagick 6.6.0-4 2012-05-02 Q16 http://www.imagemagick.org"
85  if (strpos($firstResultLine, 'ImageMagick') !== false) {
86  list(, $version) = explode('ImageMagick', $firstResultLine);
87  // Example: "6.6.0-4"
88  list($version) = explode(' ', trim($version));
89  if (version_compare($version, '6.0.0') >= 0) {
90  $this->foundPath = $path;
91  $result = true;
92  break;
93  }
94  }
95  }
96  }
97  return $result;
98  }
99 }
static exec($command, &$output=null, &$returnValue=0)