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

---

# WP_Image_Editor_GD::update_size( int $width = false, int $height = false ): true

## In this article

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

[ Back to top](https://developer.wordpress.org/reference/classes/wp_image_editor_gd/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_gd/update_size/?output_format=md#parameters)󠁿

 `$width`intoptional

Default:`false`

`$height`intoptional

Default:`false`

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

 true

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

    ```php
    protected function update_size( $width = false, $height = false ) {
    	if ( ! $width ) {
    		$width = imagesx( $this->image );
    	}

    	if ( ! $height ) {
    		$height = imagesy( $this->image );
    	}

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

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

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

| Uses | Description | 
| [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.

  |

| Used by | Description | 
| [WP_Image_Editor_GD::load()](https://developer.wordpress.org/reference/classes/wp_image_editor_gd/load/)`wp-includes/class-wp-image-editor-gd.php` |

Loads image from $this->file into new GD Resource.

  | 
| [WP_Image_Editor_GD::_resize()](https://developer.wordpress.org/reference/classes/wp_image_editor_gd/_resize/)`wp-includes/class-wp-image-editor-gd.php` |  | 
| [WP_Image_Editor_GD::crop()](https://developer.wordpress.org/reference/classes/wp_image_editor_gd/crop/)`wp-includes/class-wp-image-editor-gd.php` |

Crops Image.

  | 
| [WP_Image_Editor_GD::rotate()](https://developer.wordpress.org/reference/classes/wp_image_editor_gd/rotate/)`wp-includes/class-wp-image-editor-gd.php` |

Rotates current image counter-clockwise by $angle.

  |

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