* @uses WP_Image_Editor Extends class
*/
class WP_Image_Editor_Imagick extends WP_Image_Editor {
+ /**
+ * @var Imagick
+ */
+ protected $image; // Imagick Object
- protected $image = null; // Imagick Object
-
- function __destruct() {
+ public function __destruct() {
if ( $this->image instanceof Imagick ) {
// we don't need the original in memory anymore
$this->image->clear();
}
$updated_size = $this->update_size();
- if ( is_wp_error( $updated_size ) )
- return $updated_size;
+ if ( is_wp_error( $updated_size ) ) {
+ return $updated_size;
+ }
- return $this->set_quality( $this->quality );
+ return $this->set_quality();
}
/**
if ( is_wp_error( $quality_result ) ) {
return $quality_result;
} else {
- $quality = $this->quality;
+ $quality = $this->get_quality();
}
try {
*
* @param int $width
* @param int $height
+ *
+ * @return true|WP_Error
*/
protected function update_size( $width = null, $height = null ) {
$size = null;
}
$resize_result = $this->resize( $size_data['width'], $size_data['height'], $size_data['crop'] );
+ $duplicate = ( ( $orig_size['width'] == $size_data['width'] ) && ( $orig_size['height'] == $size_data['height'] ) );
- if( ! is_wp_error( $resize_result ) ) {
+ if ( ! is_wp_error( $resize_result ) && ! $duplicate ) {
$resized = $this->_save( $this->image );
$this->image->clear();
* @since 3.5.0
* @access public
*
- * @param string|int $src The source file or Attachment ID.
* @param int $src_x The start x position to crop from.
* @param int $src_y The start y position to crop from.
* @param int $src_w The width to crop.