Ticket #22543: 22543-5.diff
| File 22543-5.diff, 2.0 KB (added by , 13 years ago) |
|---|
-
wp-includes/class-wp-image-editor-imagick.php
38 38 * @return boolean 39 39 */ 40 40 public static function test( $args = array() ) { 41 if ( ! extension_loaded( 'imagick' ) || ! is_callable( 'Imagick', 'queryFormats' ) ) 41 42 $required_methods = array( 43 'clear', 44 'destroy', 45 'valid', 46 'getimage', 47 'writeimage', 48 'getimageblob', 49 'getimagegeometry', 50 'getimageformat', 51 'setimageformat', 52 'setimagecompression', 53 'setimagecompressionquality', 54 'setimagepage', 55 'scaleimage', 56 'cropimage', 57 'rotateimage', 58 'flipimage', 59 'flopimage', 60 ); 61 62 // Check for requirements 63 if ( ! extension_loaded( 'imagick' ) || 64 ! class_exists( 'Imagick' ) || 65 ! is_callable( 'Imagick', 'queryFormats' ) || 66 ! class_exists( 'ImagickPixel' ) || 67 ! defined( 'imagick::COMPRESSION_JPEG' ) || 68 array_diff( $required_methods, get_class_methods( 'Imagick' ) ) ) { 69 42 70 return false; 71 } 43 72 73 /** 74 * setIteratorIndex is optional unless mime is an animated format. 75 * Here, we just say no if a user is attempting to 76 * edit a GIF and setIteratorIndex isn't available. 77 */ 78 if ( ( ! isset( $args['mime_type'] ) || $args['mime_type'] == 'image/gif' ) && 79 ! method_exists( 'Imagick', 'setIteratorIndex' ) ) { 80 81 return false; 82 } 83 44 84 return true; 45 85 } 46 86 … … 88 128 if( ! $this->image->valid() ) 89 129 return new WP_Error( 'invalid_image', __('File is not an image.'), $this->file); 90 130 91 // Select the first frame to handle animated GIFs properly 92 $this->image->setIteratorIndex(0); 131 // Select the first frame to handle animated images properly 132 if ( is_callable( array( $this->image, 'setIteratorIndex' ) ) ) 133 $this->image->setIteratorIndex(0); 134 93 135 $this->mime_type = $this->get_mime_type( $this->image->getImageFormat() ); 94 136 } 95 137 catch ( Exception $e ) {