Source
File: wp-includes/class-wp-image-editor-imagick.php
public function make_subsize( $size_data ) {
if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) {
return new WP_Error( 'image_subsize_create_error', __( 'Cannot resize the image. Both width and height are not set.' ) );
}
$orig_size = $this->size;
$orig_image = $this->image->getImage();
if ( ! isset( $size_data['width'] ) ) {
$size_data['width'] = null;
}
if ( ! isset( $size_data['height'] ) ) {
$size_data['height'] = null;
}
if ( ! isset( $size_data['crop'] ) ) {
$size_data['crop'] = false;
}
$resized = $this->resize( $size_data['width'], $size_data['height'], $size_data['crop'] );
if ( is_wp_error( $resized ) ) {
$saved = $resized;
} else {
$saved = $this->_save( $this->image );
$this->image->clear();
$this->image->destroy();
$this->image = null;
}
$this->size = $orig_size;
$this->image = $orig_image;
if ( ! is_wp_error( $saved ) ) {
unset( $saved['path'] );
}
return $saved;
}