WordPress at Your Fingertips
function is not described

_rotate_image_resource() WP 2.9.0

Deprecated from version 3.5.0. It is no longer supported and can be removed in future releases. Use WP_Image_Editor::rotate() instead.

Returns an image resource. Internal use only.

This is an internal function for using it by WP core itself. It's not recommended to use this function in your code.

No Hooks.


resource|GdImage|false. GD image resource or GdImage instance, false otherwise.


_rotate_image_resource( $img, $angle );
$img(resource|GdImage) (required)
Image resource.
$angle(float|int) (required)
Image rotation angle, in degrees.



Since 2.9.0 Introduced.
Deprecated Since 3.5.0 Use WP_Image_Editor::rotate()

Code of _rotate_image_resource() WP 5.8.2

function _rotate_image_resource( $img, $angle ) {
	_deprecated_function( __FUNCTION__, '3.5.0', 'WP_Image_Editor::rotate()' );

	if ( function_exists( 'imagerotate' ) ) {
		$rotated = imagerotate( $img, $angle, 0 );

		if ( is_gd_image( $rotated ) ) {
			imagedestroy( $img );
			$img = $rotated;

	return $img;