Skip to content

Instantly share code, notes, and snippets.

@Japh
Created September 19, 2012 01:27
Show Gist options
  • Save Japh/3747095 to your computer and use it in GitHub Desktop.
Save Japh/3747095 to your computer and use it in GitHub Desktop.
ImageMagick Test for WP_Image_Editor_Imagemagick
protected function find_exec() {
exec( "type convert", $type, $type_rcode );
if ( ! $type_rcode ) {
$convert_type = explode( ' ', $type[0] );
$this->convert_bin = $convert_type[0];
} else {
exec( "locate " . escapeshellarg( "*/convert" ), $locate, $locate_rcode );
foreach ( $locate as $binary ) {
if ( '/usr/local/bin/convert' == $binary || '/usr/bin/convert' == $binary ) {
$this->convert_bin = $binary;
}
}
}
}
public static function test() {
$this->find_exec();
exec( $this->convert_bin . ' -version', $output, $return_code );
if ( $return_code )
return false;
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment