[TASK] Re-work/simplify copyright header in PHP files - Part 1
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Configuration / Image / ImageMagick6Preset.php
1 <?php
2 namespace TYPO3\CMS\Install\Configuration\Image;
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
17 use TYPO3\CMS\Install\Configuration;
18
19 /**
20 * Preset for ImageMagick version 6 or higher
21 */
22 class ImageMagick6Preset extends AbstractImagePreset implements Configuration\PresetInterface {
23
24 /**
25 * @var string Name of preset
26 */
27 protected $name = 'ImageMagick6';
28
29 /**
30 * @var integer Priority of preset
31 */
32 protected $priority = 70;
33
34 /**
35 * @var array Configuration values handled by this preset
36 */
37 protected $configurationValues = array(
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
49 /**
50 * Find executable in path, wrapper for specific ImageMagick/GraphicsMagick find methods.
51 *
52 * @param array $searchPaths
53 * @return mixed
54 */
55 protected function findExecutableInPath(array $searchPaths) {
56 return $this->findImageMagick6InPaths($searchPaths);
57 }
58
59 /**
60 * Search for GraphicsMagick executables in given paths.
61 *
62 * @param array $searchPaths List of paths to search for
63 * @return boolean TRUE if graphics magick was found in path
64 */
65 protected function findImageMagick6InPaths(array $searchPaths) {
66 $result = FALSE;
67 foreach ($searchPaths as $path) {
68 if (TYPO3_OS === 'WIN') {
69 $executable = 'identify.exe';
70 } else {
71 $executable = 'identify';
72 }
73 if (@is_file($path . $executable)) {
74 $command = escapeshellarg($path . $executable) . ' -version';
75 $executingResult = FALSE;
76 \TYPO3\CMS\Core\Utility\CommandUtility::exec($command, $executingResult);
77 // First line of exec command should contain string GraphicsMagick
78 $firstResultLine = array_shift($executingResult);
79 // Example: "Version: ImageMagick 6.6.0-4 2012-05-02 Q16 http://www.imagemagick.org"
80 if (strpos($firstResultLine, 'ImageMagick') !== FALSE) {
81 list(,$version) = explode('ImageMagick', $firstResultLine);
82 // Example: "6.6.0-4"
83 list($version) = explode(' ', trim($version));
84 if (version_compare($version, '6.0.0') >= 0) {
85 $this->foundPath = $path;
86 $result = TRUE;
87 break;
88 }
89 }
90 }
91 }
92 return $result;
93 }
94 }