I have created a webpage using php where users can upload images. I am using php GD library for image functionality. When I test that functionality, some images are automatically rotated to horizontal, even though I uploaded the image in vertical shape. Before uploading the image, I have opened it using image viewer in my computer and it shows vertical. Below is code I have used. What am I doing wrong here?
$src = imagecreatefromjpeg($originalFile);
$dest = imagecreatetruecolor($imageResizeWidth, $imageResizeHeight);
imagecopyresized($dest, $src, 0, 0, $cropCoordination[0], $cropCoordination[1], $imageResizeWidth, $imageResizeHeight, $cropCoordination[4], $cropCoordination[5]);
imagedestroy($src);
$destinationFilePath = $destinationFolderPath . DIRECTORY_SEPARATOR . $fileNameWithoutExtn . ".jpg";
if (!file_exists($destinationFolderPath)) {
mkdir($destinationFolderPath, 0777, true);
}
header('Content-Type: image/jpeg');
imagejpeg($imageResource, $destinationFilePath, 90);