WP_Image_Editor_GD::rotate

Advertisement

Summery Summery

Rotates current image counter-clockwise by $angle.

Syntax Syntax

WP_Image_Editor_GD::rotate( float $angle )

Description Description

Ported from image-edit.php

Parameters Parameters

$angle

(Required)

Return Return

(true|WP_Error)

Source Source

File: wp-includes/class-wp-image-editor-gd.php

	public function rotate( $angle ) {
		if ( function_exists( 'imagerotate' ) ) {
			$transparency = imagecolorallocatealpha( $this->image, 255, 255, 255, 127 );
			$rotated      = imagerotate( $this->image, $angle, $transparency );

			if ( is_resource( $rotated ) ) {
				imagealphablending( $rotated, true );
				imagesavealpha( $rotated, true );
				imagedestroy( $this->image );
				$this->image = $rotated;
				$this->update_size();
				return true;
			}
		}
		return new WP_Error( 'image_rotate_error', __( 'Image rotate failed.' ), $this->file );
	}

Advertisement

Changelog Changelog

Changelog
Version Description
3.5.0 Introduced.

Advertisement

Leave a Reply