縦向きに撮影した写真をPHPでアップロードするとなぜか、PCで横倒しの状態になって表示されます。
調べていくとExif 情報というのが影響していることがわかりました。
private function Rotate_Images($filename){ $file = $_SERVER["DOCUMENT_ROOT"]."/image/".$filename; $im = new Imagick($file); $orientation = $im->getImageOrientation(); switch ($orientation) { case 2: $im->flopImage(); break; case 3: $im->rotateImage('#000000', 180); break; case 4: $im->flipImage(); break; case 5: $im->flopImage(); $im->rotateImage('#000000', 270); break; case 6: $im->rotateImage('#000000', 90); break; case 7: $im->flopImage(); $im->rotateImage('#000000', 90); break; case 8: $im->rotateImage('#000000', 270); break; } $im->stripImage(); $im->writeImage($file); }
データを取得して表示する段階でExif 情報を書き換えれば対処できると思い、やってみたのですが、横倒しの画像の状態で表示されます。
プログラム自身が間違っているのか?
考え方からして、UPLOAD時に対処すべき処理なのか、どちらが正しいでしょうか?
FTPソフトでサーバ上の画像を見ると縦方向で保存されていました。
宜しくお願いいたします。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/08/26 09:01
2017/08/26 09:13
2017/08/26 09:24
2017/08/26 12:40
2017/08/26 13:21
2017/08/26 22:09
2017/08/27 00:15
2017/08/27 00:25