Skip to content

Commit 4af3b37

Browse files
committed
get version via php
instead of using convert get the imagemagick version via php instead. also adds supports for graphicsmagick to gather more data when possible.
1 parent 956a061 commit 4af3b37

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

functions.php

Lines changed: 12 additions & 0 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,6 +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' ) );
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+
}
217229
$env['system_utils']['openssl'] = str_replace( 'OpenSSL ', '', trim( shell_exec( 'openssl version' ) ) );
218230
return $env;
219231
}

prepare.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
'mod_xml',
6767
'mysqli',
6868
'imagick',
69+
'gmagick',
6970
'pcre',
7071
'xml',
7172
'xmlreader',
@@ -78,6 +79,17 @@
7879
\$curl = array_shift( \$curl_bits );
7980
\$env['system_utils']['curl'] = trim( \$curl );
8081
\$env['system_utils']['ghostscript'] = trim( shell_exec( 'gs --version' ) );
82+
if ( class_exists( 'Imagick' ) ) {
83+
\$imagick = new Imagick();
84+
\$version = \$imagick->getVersion();
85+
preg_match( '/Magick (\d+\.\d+\.\d+-\d+|\d+\.\d+\.\d+|\d+\.\d+\-\d+|\d+\.\d+)/', \$version['versionString'], \$version );
86+
\$env['system_utils']['imagemagick'] = \$version[1];
87+
} elseif ( class_exists( 'Gmagick' ) ) {
88+
\$gmagick = new Gmagick();
89+
\$version = \$gmagick->getversion();
90+
preg_match( '/Magick (\d+\.\d+\.\d+-\d+|\d+\.\d+\.\d+|\d+\.\d+\-\d+|\d+\.\d+)/', \$version['versionString'], \$version );
91+
\$env['system_utils']['graphicsmagick'] = \$version[1];
92+
}
8193
\$env['system_utils']['openssl'] = str_replace( 'OpenSSL ', '', trim( shell_exec( 'openssl version' ) ) );
8294
file_put_contents( __DIR__ . '/tests/phpunit/build/logs/env.json', json_encode( \$env, JSON_PRETTY_PRINT ) );
8395
if ( 'cli' === php_sapi_name() && defined( 'WP_INSTALLING' ) && WP_INSTALLING ) {

0 commit comments

Comments
 (0)