WP_Image_Editor_GD::rotate() public WP 3.5.0
Rotates current image counter-clockwise by $angle. Ported from image-edit.php
{} It's a method of the class: WP_Image_Editor_GD{}
No Hooks.
Return
true/WP_Error.
Usage
$WP_Image_Editor_GD = new WP_Image_Editor_GD(); $WP_Image_Editor_GD->rotate( $angle );
- $angle(float) (required)
Changelog
Since 3.5.0 | Introduced. |
Code of WP_Image_Editor_GD::rotate() WP Image Editor GD::rotate WP 5.6
public function rotate( $angle ) {
if ( function_exists( 'imagerotate' ) ) {
$transparency = imagecolorallocatealpha( $this->image, 255, 255, 255, 127 );
$rotated = imagerotate( $this->image, $angle, $transparency );
if ( is_gd_image( $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 );
}