$myfile = fopen("log.txt", "w") or die("Unable to open file!");
fwrite($myfile, "LOG\n");
fclose($myfile);
//define image path
$filename="photos/".$_GET['onlyImage3'];
// Load the image
$source = imagecreatefromjpeg($filename) or fwrite($myfile, "FAIL1\n");
// Set the content type header - in this case image/jpeg
//header('Content-Type: image/jpeg');
// Rotate
$rotate = imagerotate($source, +180, 0);
//and save it on your server...
$filename = str_replace(".jpg", "_r.jpg", $filename);
//file_put_contents($filename,$rotate);
//$text_color = imagecolorallocate($rotate, 233, 14, 91);
//imagestring($rotate, 1, 5, 5, 'A Simple Text String', $text_color);
imagejpeg($rotate, $filename);
imagedestroy($rotate);
imagedestroy($source);