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

---

# WP_Image_Editor_Imagick::update_size( int $width = null, int $height = null ): true|󠀁[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)󠁿

## In this article

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

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

Sets or updates current image size.

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

 `$width`intoptional

Default:`null`

`$height`intoptional

Default:`null`

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/update_size/?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/update_size/?output_format=md#source)󠁿

    ```php
    protected function update_size( $width = null, $height = null ) {
    	$size = null;
    	if ( ! $width || ! $height ) {
    		try {
    			$size = $this->image->getImageGeometry();
    		} catch ( Exception $e ) {
    			return new WP_Error( 'invalid_image', __( 'Could not read image size.' ), $this->file );
    		}
    	}

    	if ( ! $width ) {
    		$width = $size['width'];
    	}

    	if ( ! $height ) {
    		$height = $size['height'];
    	}

    	/*
    	 * If we still don't have the image size, fall back to `wp_getimagesize`. This ensures AVIF and HEIC images
    	 * are properly sized without affecting previous `getImageGeometry` behavior.
    	 */
    	if ( ( ! $width || ! $height ) && ( 'image/avif' === $this->mime_type || wp_is_heic_image_mime_type( $this->mime_type ) ) ) {
    		$size   = wp_getimagesize( $this->file );
    		$width  = $size[0];
    		$height = $size[1];
    	}

    	return parent::update_size( $width, $height );
    }
    ```

[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#L254)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/class-wp-image-editor-imagick.php#L254-L283)

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

| Uses | Description | 
| [wp_is_heic_image_mime_type()](https://developer.wordpress.org/reference/functions/wp_is_heic_image_mime_type/)`wp-includes/functions.php` |

Checks if a mime type is for a HEIC/HEIF image.

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

Allows PHP’s getimagesize() to be debuggable when necessary.

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

Sets current image size.

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

Retrieves the translation of $text.

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

Initializes the error.

  |

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

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

Resizes 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::rotate()](https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/rotate/)`wp-includes/class-wp-image-editor-imagick.php` |

Rotates current image counter-clockwise by $angle.

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

Loads image from $this->file into new Imagick Object.

  |

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