0

I try to rotate the uploaded image 90 degrees after uploading, I tried imagerotate() method, but it's not working.

Here is my code:

$tmp = $_FILES['photoimg']['tmp_name']; 
$path = "uploads/";  
move_uploaded_file($tmp, $path."newfile.jpg");  
$rotate = imagerotate($path."newfile.jpg", 90, 0);
imagejpeg($rotate);
imagedestroy($source);
imagedestroy($rotate);

Any help will be greately appreciated, thanks!

1 Answer 1

2

imagerotate needs a resource as first parameter not a file path. You should get an error if you'd enable error reporting. error_reporting(E_ALL);

$source = imagecreatefromjpeg($path."newfile.jpg");
$rotate = imagerotate($source, 90, 0);
imagejpeg($rotate);
imagedestroy($source);
imagedestroy($rotate);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.