with large file, where imagerotate is missing, you can use, when possible "convert" command from ImageMagick. Here is a sample script.
<?php
error_reporting(E_ALL);
header("Content-type: image/png");
$file = 'images/test/imgp2498.jpg';
image_rotate_with_convert($file, 90);
function image_rotate_with_convert($file, $angle){
passthru("convert -rotate $angle $file -");
}
?>