I just want to do a simple code that Open, Rotate and Save it back under the same name. I believe that I have found the building blocks in different threads but something is wrong.
$filename = './uploads/' . $newNamePrefix . $_FILES['fileToUpload']['name'];
$degrees = 180;
// Load
$source = imagecreatefromjpeg($filename);
// Rotate
$rotate = imagerotate($source, $degrees, 0);
// Save
echo imagejpeg($rotate. $filename);
// Free the memory
imagedestroy($source);
imagedestroy($rotate);
Everything except the save part seem to work.
Any ideas?
Thanks!
You have a typo in your imagejpeg
call; you need a comma to separate the arguments, instead of a period (which is trying to concatenate the image handle and the filename together as a string).
If you have warnings turned on (always a good idea during development), you would see something like this:
PHP Warning: imagejpeg() expects parameter 1 to be resource, string given in something.php on line ...