I have a script that downloads a file. I added a function that should rotate the image for photos downloaded from iPhone or iPad .. because depending on how they were taken, they could be displayed sideways or upside down. I think I understood the code correctly, but for some reason it still doesn’t spin when loading. What am I doing wrong?
$uploadedFileName = $this->relative_path . $base_dir . $file_name;
$is_upload = @copy($file_details['tmp_name'], $uploadedFileName);
$exif = exif_read_data($uploadedFileName);
$orientation = $exif['COMPUTED']['Orientation'];
if (isset($orientation)) {
switch ($orientation) {
case 3:
$image_p = imagerotate($uploadedFileName, 180, 0);
break;
case 6:
$image_p = imagerotate($uploadedFileName, -90, 0);
break;
case 8:
$image_p = imagerotate($uploadedFileName, 90, 0);
break;
}
imagejpeg($image_p, $uploadedFileName, 100);
}
source
share