diff --git src/wp-includes/class-wp-image-editor-imagick.php src/wp-includes/class-wp-image-editor-imagick.php
index 7e6ffd1..e366b65 100644
|
|
class WP_Image_Editor_Imagick extends WP_Image_Editor { |
62 | 62 | 'writeimage', |
63 | 63 | 'getimageblob', |
64 | 64 | 'getimagegeometry', |
65 | | 'getimagedepth', |
66 | 65 | 'getimageformat', |
67 | 66 | 'setimageformat', |
68 | 67 | 'setimagecompression', |
69 | 68 | 'setimagecompressionquality', |
70 | 69 | 'setimagedepth', |
71 | 70 | 'setimagepage', |
72 | | 'setimageproperty', |
73 | | 'setinterlacescheme', |
74 | 71 | 'scaleimage', |
75 | 72 | 'cropimage', |
76 | 73 | 'rotateimage', |
77 | 74 | 'flipimage', |
78 | 75 | 'flopimage', |
79 | | 'unsharpmaskimage', |
80 | 76 | ); |
81 | 77 | |
82 | 78 | // Now, test for deep requirements within Imagick. |
83 | | if ( ! ( defined( 'imagick::COMPRESSION_JPEG' ) && defined( 'imagick::FILTER_TRIANGLE' ) ) ) |
| 79 | if ( ! ( defined( 'imagick::COMPRESSION_JPEG' ) ) ) |
84 | 80 | return false; |
85 | 81 | |
86 | 82 | if ( array_diff( $required_methods, get_class_methods( 'Imagick' ) ) ) |
… |
… |
class WP_Image_Editor_Imagick extends WP_Image_Editor { |
304 | 300 | if ( in_array( $filter_name, $allowed_filters ) && defined( 'Imagick::' . $filter_name ) ) { |
305 | 301 | $filter = constant( 'Imagick::' . $filter_name ); |
306 | 302 | } else { |
307 | | $filter = Imagick::FILTER_TRIANGLE; |
| 303 | $filter = defnined( Imagick::FILTER_TRIANGLE ) ? Imagick::FILTER_TRIANGLE : false; |
308 | 304 | } |
309 | 305 | |
310 | 306 | /** |
… |
… |
class WP_Image_Editor_Imagick extends WP_Image_Editor { |
327 | 323 | * whenever the output size is less that 1/3 of the original image size (1/3^2 ~= .111), |
328 | 324 | * unless we would be resampling to a scale smaller than 128x128. |
329 | 325 | */ |
330 | | $resize_ratio = ( $dst_w / $this->size['width'] ) * ( $dst_h / $this->size['height'] ); |
331 | | $sample_factor = 5; |
| 326 | if ( method_exists( $this->image, 'sampleImage') ) { |
| 327 | $resize_ratio = ( $dst_w / $this->size['width'] ) * ( $dst_h / $this->size['height'] ); |
| 328 | $sample_factor = 5; |
332 | 329 | |
333 | | if ( $resize_ratio < .111 && ( $dst_w * $sample_factor > 128 && $dst_h * $sample_factor > 128 ) ) { |
334 | | $this->image->sampleImage( $dst_w * $sample_factor, $dst_h * $sample_factor ); |
| 330 | if ( $resize_ratio < .111 && ( $dst_w * $sample_factor > 128 && $dst_h * $sample_factor > 128 ) ) { |
| 331 | $this->image->sampleImage( $dst_w * $sample_factor, $dst_h * $sample_factor ); |
| 332 | } |
335 | 333 | } |
336 | 334 | |
337 | | // Resize to the final output size. |
338 | | $this->image->setOption( 'filter:support', '2.0' ); |
339 | | $this->image->resizeImage( $dst_w, $dst_h, $filter, 1 ); |
| 335 | /** |
| 336 | * Use resizeImage() when it's availalbe and a valid filter value is set. |
| 337 | * Otherwise, fall back to the scaleImage() method for resizing, which |
| 338 | * results in better image quality over resizeImage() with default filter |
| 339 | * settings and retains backwards compatability with pre 4.5 functionality. |
| 340 | */ |
| 341 | if ( method_exists( $this->image, 'resizeImage') && $filter ) { |
| 342 | $this->image->setOption( 'filter:support', '2.0' ); |
| 343 | $this->image->resizeImage( $dst_w, $dst_h, $filter, 1 ); |
| 344 | } else { |
| 345 | $this->image->scaleImage( $dst_w, $dst_h ); |
| 346 | } |
340 | 347 | |
341 | 348 | // Set appropriate quality settings after resizing. |
342 | 349 | if ( 'image/jpeg' == $this->mime_type ) { |
343 | | $this->image->unsharpMaskImage( 0.25, 0.25, 8, 0.065 ); |
| 350 | if ( method_exists( $this->image, 'unsharpMaskImage') ) { |
| 351 | $this->image->unsharpMaskImage( 0.25, 0.25, 8, 0.065 ); |
| 352 | } |
| 353 | |
344 | 354 | $this->image->setOption( 'jpeg:fancy-upsampling', 'off' ); |
345 | 355 | } |
346 | 356 | |
… |
… |
class WP_Image_Editor_Imagick extends WP_Image_Editor { |
362 | 372 | } |
363 | 373 | |
364 | 374 | // Limit the bit depth of resized images to 8 bits per channel. |
365 | | if ( 8 < $this->image->getImageDepth() ) { |
| 375 | if ( method_exists( $this->image, 'getImageDepth' ) && 8 < $this->image->getImageDepth() ) { |
366 | 376 | $this->image->setImageDepth( 8 ); |
367 | 377 | } |
368 | 378 | |
369 | | $this->image->setInterlaceScheme( Imagick::INTERLACE_NO ); |
| 379 | if ( method_exists( $this->image, 'setInterlaceScheme' ) && defined( 'Imagick::INTERLACE_NO' ) ) { |
| 380 | $this->image->setInterlaceScheme( Imagick::INTERLACE_NO ); |
| 381 | } |
370 | 382 | |
371 | 383 | } |
372 | 384 | catch ( Exception $e ) { |