明明就是直的,你程式有問題,還是眼睛有問題
主要原因是圖片有帶一個旋轉的參數 Orientation
原本是橫的圖片,因為有帶 Orientation 這個參數所以在windows打開看起來是直的
但骨子裡他是橫的圖片,PHP也覺得是橫的,但客戶覺得明明就是直的,是你程式有問題
好吧!! 所以在PHP圖片輸出前把它轉回來
假設圖片轉了90度,就用PHP再旋轉-90度把它轉回來,就跟客戶看的一樣是直的了
可參考下列程式:
<?php
$image = imagecreatefromstring(file_get_contents($_FILES['image_upload']['tmp_name']));
$exif = exif_read_data($_FILES['image_upload']['tmp_name']);
if(!empty($exif['Orientation'])) {
    switch($exif['Orientation']) {
        case 8:
            $image = imagerotate($image,90,0);
            break;
        case 3:
            $image = imagerotate($image,180,0);
            break;
        case 6:
            $image = imagerotate($image,-90,0);
            break;
    }
}
// $image now contains a resource with the image oriented correctly
?>