How can I rotate an image?

Answer Posted / jude jeevanraj.p

Probably not something you will want to do a lot of in
ordinary day PHP use, but if you want to rotate an image
use the well-named imagerotate function.

This takes the image to rotate, the angle of rotation, and
a color to fill the blank space around the rotated image
with.

Here's an example:
<?php
$original = imagecreatefrompng("myimage.png");
$red = imageColorAllocate($original,255,0,0);
imagerotate($original,50,$red);
header("content-type:image/png");
imagepng($rotated);
imagedestroy($original);
imagedestroy($rotated);
?>

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is php and why it is used?

545


What is csrf token and how will you add csrf token in ajax?

523


How to convert a string to uppercase in php?

543


Why do we need session?

537


What is needed to be able to use image function?

523






Tell us what does $_cookie means?

569


What are the new features available in php 7?

542


What is the importance of php?

522


What is the use of strpos in php?

552


What does isset() function?

541


How can php and html interact?

614


What is a closure in php?

533


What is a http session?

541


Inside a php function, what param needs to be set in order to access a global variable?

537


What are Routines?

1776