[TASK] Remove GFX im_imvMaskState and im_negate_mask settings
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Configuration / Image / GraphicsMagickPreset.php
1 <?php
2 namespace TYPO3\CMS\Install\Configuration\Image;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 use TYPO3\CMS\Install\Configuration;
28
29 /**
30 * Preset for GraphicsMagick
31 */
32 class GraphicsMagickPreset extends AbstractImagePreset implements Configuration\PresetInterface {
33
34 /**
35 * @var string Name of preset
36 */
37 protected $name = 'GraphicsMagick';
38
39 /**
40 * @var integer Priority of preset
41 */
42 protected $priority = 80;
43
44 /**
45 * @var array Configuration values handled by this preset
46 */
47 protected $configurationValues = array(
48 'GFX/image_processing' => 1,
49 'GFX/im' => 1,
50 // im_path and im_path_lzw are determined and set by path lookup methods
51 'GFX/im_path' => '',
52 'GFX/im_path_lzw' => '',
53 'GFX/im_version_5' => 'gm',
54 'GFX/im_v5effects' => -1,
55 'GFX/im_mask_temp_ext_gif' => 1,
56 'GFX/colorspace' => 'RGB',
57 );
58
59 /**
60 * Find executable in path, wrapper for specific ImageMagick/GraphicsMagick find methods.
61 *
62 * @param array $searchPaths
63 * @return mixed
64 */
65 protected function findExecutableInPath(array $searchPaths) {
66 return $this->findGraphicsMagickInPaths($searchPaths);
67 }
68
69 /**
70 * Search for GraphicsMagick executables in given paths.
71 *
72 * @param array $searchPaths List of pathes to search for
73 * @return boolean TRUE if graphics magick was found in path
74 */
75 protected function findGraphicsMagickInPaths(array $searchPaths) {
76 $result = FALSE;
77 foreach ($searchPaths as $path) {
78 if (TYPO3_OS === 'WIN') {
79 $executable = 'gm.exe';
80 } else {
81 $executable = 'gm';
82 }
83 if (@is_dir($path) && @is_file($path . $executable)) {
84 $command = escapeshellarg($path . $executable) . ' -version';
85 $executingResult = FALSE;
86 \TYPO3\CMS\Core\Utility\CommandUtility::exec($command, $executingResult);
87 // First line of exec command should contain string GraphicsMagick
88 $firstResultLine = array_shift($executingResult);
89 if (strpos($firstResultLine, 'GraphicsMagick') !== FALSE) {
90 $this->foundPath = $path;
91 $result = TRUE;
92 break;
93 }
94 }
95 }
96 return $result;
97 }
98 }
99 ?>