I am working on a simple php upload script. it works fine. but for some reason, when the images are compressed, they rotate. sometimes they rotate completely 180 degrees, sometimes 90 degrees. Why is it doing this and how do i stop it? here is my code :
$name = ''; $type = ''; $size = ''; $error = '';
function compress_image($source_url, $destination_url, $quality) {
$info = getimagesize($source_url);
if ($info['mime'] == 'image/jpeg')
$image = imagecreatefromjpeg($source_url);
elseif ($info['mime'] == 'image/gif')
$image = imagecreatefromgif($source_url);
elseif ($info['mime'] == 'image/png')
$image = imagecreatefrompng($source_url);
imagejpeg($image, $destination_url, $quality);
//echo "result ".$destination_url;
//correctImageOrientation($destination_url);
return $destination_url;
}
$url = 'test/compressed.jpg';
compress_image($_FILES["file"]["tmp_name"], $url, 30);