Title: WP_Image_Editor_Imagick::resize
Published: April 25, 2014
Last modified: May 20, 2026

---

# WP_Image_Editor_Imagick::resize( int|null $max_w, int|null $max_h, bool|array $crop = false ): true|󠀁[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)󠁿

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/resize/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/resize/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/resize/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/resize/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/resize/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/resize/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/resize/?output_format=md#wp--skip-link--target)

Resizes current image.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/resize/?output_format=md#description)󠁿

At minimum, either a height or width must be provided.
If one of the two is set 
to null, the resize will maintain aspect ratio according to the provided dimension.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/resize/?output_format=md#parameters)󠁿

 `$max_w`int|nullrequired

Image width.

`$max_h`int|nullrequired

Image height.

`$crop`bool|arrayoptional

Image cropping behavior. If false, the image will be scaled (default).
 If true,
image will be cropped to the specified dimensions using center positions. If an 
array, the image will be cropped using the array to specify the crop location:

 * `0` string
 * The x crop position. Accepts `'left'`, `'center'`, or `'right'`.
 * `1` string
 * The y crop position. Accepts `'top'`, `'center'`, or `'bottom'`.

Default:`false`

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/resize/?output_format=md#return)󠁿

 true|[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/resize/?output_format=md#source)󠁿

    ```php
    public function resize( $max_w, $max_h, $crop = false ) {
    	if ( ( $this->size['width'] === $max_w ) && ( $this->size['height'] === $max_h ) ) {
    		return true;
    	}

    	$dims = image_resize_dimensions( $this->size['width'], $this->size['height'], $max_w, $max_h, $crop );
    	if ( ! $dims ) {
    		return new WP_Error( 'error_getting_dimensions', __( 'Could not calculate resized image dimensions' ) );
    	}

    	list( $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ) = $dims;

    	if ( $crop ) {
    		return $this->crop( $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h );
    	}

    	$this->set_quality(
    		null,
    		array(
    			'width'  => $dst_w,
    			'height' => $dst_h,
    		)
    	);

    	// Execute the resize.
    	$thumb_result = $this->thumbnail_image( $dst_w, $dst_h );
    	if ( is_wp_error( $thumb_result ) ) {
    		return $thumb_result;
    	}

    	return $this->update_size( $dst_w, $dst_h );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-image-editor-imagick.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/class-wp-image-editor-imagick.php#L356)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/class-wp-image-editor-imagick.php#L356-L387)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/resize/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Image_Editor_Imagick::thumbnail_image()](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/thumbnail_image/)`wp-includes/class-wp-image-editor-imagick.php` |

Efficiently resize the current image

  | 
| [WP_Image_Editor_Imagick::crop()](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/crop/)`wp-includes/class-wp-image-editor-imagick.php` |

Crops Image.

  | 
| [WP_Image_Editor_Imagick::update_size()](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/update_size/)`wp-includes/class-wp-image-editor-imagick.php` |

Sets or updates current image size.

  | 
| [WP_Image_Editor_Imagick::set_quality()](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/set_quality/)`wp-includes/class-wp-image-editor-imagick.php` |

Sets Image Compression quality on a 1-100% scale.

  | 
| [image_resize_dimensions()](https://developer.wordpress.org/reference/functions/image_resize_dimensions/)`wp-includes/media.php` |

Retrieves calculated resize dimensions for use in [WP_Image_Editor](https://developer.wordpress.org/reference/classes/wp_image_editor/).

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [is_wp_error()](https://developer.wordpress.org/reference/functions/is_wp_error/)`wp-includes/load.php` |

Checks whether the given variable is a WordPress Error.

  | 
| [WP_Error::__construct()](https://developer.wordpress.org/reference/classes/wp_error/__construct/)`wp-includes/class-wp-error.php` |

Initializes the error.

  |

[Show 3 more](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/resize/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/resize/?output_format=md#)

| Used by | Description | 
| [WP_Image_Editor_Imagick::make_subsize()](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/make_subsize/)`wp-includes/class-wp-image-editor-imagick.php` |

Create an image sub-size and return the image meta data value for it.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/resize/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.5.0](https://developer.wordpress.org/reference/since/3.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_image_editor_imagick%2Fresize%2F)
before being able to contribute a note or feedback.