Clean up WP_Image_Editor_Imagick::test(). Props DH-Shredder. see #22543
git-svn-id: http://core.svn.wordpress.org/trunk@22864 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d4159bf041
commit
1afc32e84a
|
@ -39,6 +39,10 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor {
|
||||||
*/
|
*/
|
||||||
public static function test( $args = array() ) {
|
public static function test( $args = array() ) {
|
||||||
|
|
||||||
|
// First, test Imagick's extension and classes.
|
||||||
|
if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick' ) || ! class_exists( 'ImagickPixel' ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
$required_methods = array(
|
$required_methods = array(
|
||||||
'clear',
|
'clear',
|
||||||
'destroy',
|
'destroy',
|
||||||
|
@ -59,28 +63,14 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor {
|
||||||
'flopimage',
|
'flopimage',
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check for requirements
|
// Now, test for deep requirements within Imagick.
|
||||||
if ( ! extension_loaded( 'imagick' ) ||
|
if ( ! is_callable( 'Imagick', 'queryFormats' ) ||
|
||||||
! class_exists( 'Imagick' ) ||
|
|
||||||
! is_callable( 'Imagick', 'queryFormats' ) ||
|
|
||||||
! class_exists( 'ImagickPixel' ) ||
|
|
||||||
! defined( 'imagick::COMPRESSION_JPEG' ) ||
|
! defined( 'imagick::COMPRESSION_JPEG' ) ||
|
||||||
array_diff( $required_methods, get_class_methods( 'Imagick' ) ) ) {
|
array_diff( $required_methods, get_class_methods( 'Imagick' ) ) ) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* setIteratorIndex is optional unless mime is an animated format.
|
|
||||||
* Here, we just say no if a user is attempting to
|
|
||||||
* edit a GIF and setIteratorIndex isn't available.
|
|
||||||
*/
|
|
||||||
if ( ( ! isset( $args['mime_type'] ) || $args['mime_type'] == 'image/gif' ) &&
|
|
||||||
! method_exists( 'Imagick', 'setIteratorIndex' ) ) {
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,6 +89,11 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor {
|
||||||
if ( ! $imagick_extension )
|
if ( ! $imagick_extension )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// setIteratorIndex is optional unless mime is an animated format.
|
||||||
|
// Here, we just say no if you are missing it and aren't loading a jpeg.
|
||||||
|
if ( ! method_exists( 'Imagick', 'setIteratorIndex' ) && $mime_type != 'image/jpeg' )
|
||||||
|
return false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return ( (bool) Imagick::queryFormats( $imagick_extension ) );
|
return ( (bool) Imagick::queryFormats( $imagick_extension ) );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue