TYPO3 CMS  TYPO3_7-6
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/image_processing' => 1,
39  'GFX/im' => 1,
40  // im_path and im_path_lzw are determined and set by path lookup methods
41  'GFX/im_path' => '',
42  'GFX/im_path_lzw' => '',
43  'GFX/im_version_5' => 'im6',
44  'GFX/im_v5effects' => 1,
45  'GFX/im_mask_temp_ext_gif' => 1,
46  'GFX/colorspace' => 'sRGB',
47  ];
48 
55  protected function findExecutableInPath(array $searchPaths)
56  {
57  return $this->findImageMagick6InPaths($searchPaths);
58  }
59 
66  protected function findImageMagick6InPaths(array $searchPaths)
67  {
68  $result = false;
69  foreach ($searchPaths as $path) {
70  if (TYPO3_OS === 'WIN') {
71  $executable = 'identify.exe';
72  } else {
73  $executable = 'identify';
74  }
75  if (@is_file($path . $executable)) {
76  $command = escapeshellarg($path . $executable) . ' -version';
77  $executingResult = false;
78  \TYPO3\CMS\Core\Utility\CommandUtility::exec($command, $executingResult);
79  // First line of exec command should contain string GraphicsMagick
80  $firstResultLine = array_shift($executingResult);
81  // Example: "Version: ImageMagick 6.6.0-4 2012-05-02 Q16 http://www.imagemagick.org"
82  if (strpos($firstResultLine, 'ImageMagick') !== false) {
83  list(, $version) = explode('ImageMagick', $firstResultLine);
84  // Example: "6.6.0-4"
85  list($version) = explode(' ', trim($version));
86  if (version_compare($version, '6.0.0') >= 0) {
87  $this->foundPath = $path;
88  $result = true;
89  break;
90  }
91  }
92  }
93  }
94  return $result;
95  }
96 }
static exec($command, &$output=null, &$returnValue=0)