Title: WP_Image_Editor::resize
Published: April 25, 2014
Last modified: August 20, 2026

---

# WP_Image_Editor::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/resize/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_image_editor/resize/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_image_editor/resize/?output_format=md#return)
 * [More Information](https://developer.wordpress.org/reference/classes/wp_image_editor/resize/?output_format=md#more-information)
 * [Source](https://developer.wordpress.org/reference/classes/wp_image_editor/resize/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_image_editor/resize/?output_format=md#changelog)

Resizes current image.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_image_editor/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/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/resize/?output_format=md#return)󠁿

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

## 󠀁[More Information](https://developer.wordpress.org/reference/classes/wp_image_editor/resize/?output_format=md#more-information)󠁿

Crop value:

 1. If false (default), images will not be cropped.
 2. If an array in the form of array( x_crop_position, y_crop_position ):
    – x_crop_position
    accepts ‘left’ ‘center’, or ‘right’.– y_crop_position accepts ‘top’, ‘center’, 
    or ‘bottom’.
 3. Images will be cropped to the specified dimensions within the defined crop area.
 4. If true, images will be cropped to the specified dimensions using center p.

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

    ```php
    abstract public function resize( $max_w, $max_h, $crop = false );
    ```

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

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_image_editor/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%2Fresize%2F)
before being able to contribute a note or feedback.