Skip to content

Commit 4507c9a

Browse files
authored
Merge pull request #137 from mrxkon/remove-shell_exec-convert
Remove shell exec convert
2 parents 8fdff5c + 4af3b37 commit 4507c9a

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

functions.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ function get_env_details() {
202202
'mod_xml',
203203
'mysqli',
204204
'imagick',
205+
'gmagick',
205206
'pcre',
206207
'xml',
207208
'xmlreader',
@@ -214,9 +215,17 @@ function get_env_details() {
214215
$curl = array_shift( $curl_bits );
215216
$env['system_utils']['curl'] = trim( $curl );
216217
$env['system_utils']['ghostscript'] = trim( shell_exec( 'gs --version' ) );
217-
$ret = shell_exec( 'convert --version' );
218-
preg_match( '#Version: ImageMagick ([^\s]+)#', $ret, $matches );
219-
$env['system_utils']['imagemagick'] = isset( $matches[1] ) ? $matches[1] : false;
218+
if ( class_exists( 'Imagick' ) ) {
219+
$imagick = new Imagick();
220+
$version = $imagick->getVersion();
221+
preg_match( '/Magick (\d+\.\d+\.\d+-\d+|\d+\.\d+\.\d+|\d+\.\d+\-\d+|\d+\.\d+)/', $version['versionString'], $version );
222+
$env['system_utils']['imagemagick'] = $version[1];
223+
} elseif ( class_exists( 'Gmagick' ) ) {
224+
$gmagick = new Gmagick();
225+
$version = $gmagick->getversion();
226+
preg_match( '/Magick (\d+\.\d+\.\d+-\d+|\d+\.\d+\.\d+|\d+\.\d+\-\d+|\d+\.\d+)/', $version['versionString'], $version );
227+
$env['system_utils']['graphicsmagick'] = $version[1];
228+
}
220229
$env['system_utils']['openssl'] = str_replace( 'OpenSSL ', '', trim( shell_exec( 'openssl version' ) ) );
221230
return $env;
222231
}

prepare.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
'mod_xml',
6666
'mysqli',
6767
'imagick',
68+
'gmagick',
6869
'pcre',
6970
'xml',
7071
'xmlreader',
@@ -77,9 +78,17 @@
7778
\$curl = array_shift( \$curl_bits );
7879
\$env['system_utils']['curl'] = trim( \$curl );
7980
\$env['system_utils']['ghostscript'] = trim( shell_exec( 'gs --version' ) );
80-
\$ret = shell_exec( 'convert --version' );
81-
preg_match( '#Version: ImageMagick ([^\s]+)#', \$ret, \$matches );
82-
\$env['system_utils']['imagemagick'] = isset( \$matches[1] ) ? \$matches[1] : false;
81+
if ( class_exists( 'Imagick' ) ) {
82+
\$imagick = new Imagick();
83+
\$version = \$imagick->getVersion();
84+
preg_match( '/Magick (\d+\.\d+\.\d+-\d+|\d+\.\d+\.\d+|\d+\.\d+\-\d+|\d+\.\d+)/', \$version['versionString'], \$version );
85+
\$env['system_utils']['imagemagick'] = \$version[1];
86+
} elseif ( class_exists( 'Gmagick' ) ) {
87+
\$gmagick = new Gmagick();
88+
\$version = \$gmagick->getversion();
89+
preg_match( '/Magick (\d+\.\d+\.\d+-\d+|\d+\.\d+\.\d+|\d+\.\d+\-\d+|\d+\.\d+)/', \$version['versionString'], \$version );
90+
\$env['system_utils']['graphicsmagick'] = \$version[1];
91+
}
8392
\$env['system_utils']['openssl'] = str_replace( 'OpenSSL ', '', trim( shell_exec( 'openssl version' ) ) );
8493
file_put_contents( __DIR__ . '/tests/phpunit/build/logs/env.json', json_encode( \$env, JSON_PRETTY_PRINT ) );
8594
if ( 'cli' === php_sapi_name() && defined( 'WP_INSTALLING' ) && WP_INSTALLING ) {

0 commit comments

Comments
 (0)