php image rotation not working as expected -


i using php rotate photo on server. when click button 'rotate' use ajax load php page, perform rotation , refresh div new image.

everything works , image has been rotated correct dimensions image hasn't rotated. if hit f5 refresh page, image displayed corrected. know why image isn't displayed correctly before refreshing.

$photo_path= $result['photo_path']; $src = imagecreatefromjpeg($photo_path); $rotate = imagerotate($src, 90, 0); @unlink($photo_path); imagejpeg($rotate,$photo_path); imagedestroy($src); imagedestroy($rotate); 

any ideas?

try this,

$file="myimage.jpg";  $file1 = imagecreatefromjpeg($file);  $file2 = imagerotate($file1, $degrees, 0);  file_put_contents("newimage.jpg",$file2); 

Comments