I made a web page for an artist friend so she could upload photos of her pictures and add her own titles and descriptions. The problem is that when she uploads from her phone the images are the wrong way round. Found methods on Google and I was hoping to make it easy for her by rotating 90' every time she clicked an image. Simple test code below.
The problem with it is that rotate only works once on any given image, call the code a second time and nowt happens. Even changing rotation degrees makes no difference. Any ideas? Cheers.
PHP stuff:
$filename = getcwd()."/20200526_100502.jpg";
rotate($filename);
function rotate($filename)
{
$imageResource = imagecreatefromjpeg($filename);
$image = imagerotate($imageResource,-180,0);
imagejpeg($image, $filename);
imagedestroy($imageResource);
imagedestroy($image);
}
html stuff.....
<img class='img' src='20200526_100502.jpg'>
The problem with it is that rotate only works once on any given image, call the code a second time and nowt happens. Even changing rotation degrees makes no difference. Any ideas? Cheers.
PHP stuff:
$filename = getcwd()."/20200526_100502.jpg";
rotate($filename);
function rotate($filename)
{
$imageResource = imagecreatefromjpeg($filename);
$image = imagerotate($imageResource,-180,0);
imagejpeg($image, $filename);
imagedestroy($imageResource);
imagedestroy($image);
}
html stuff.....
<img class='img' src='20200526_100502.jpg'>
Comment