iphoneなどでとった写真には位置情報や回転情報があるがexifを削除すると 回転情報が消えて画像の向きがおかしくなるので回転情報だけは保持するようにする
exiftool ・ Image Magick で Exif Orientation 情報を追加・編集する
http://kuteken.hatenablog.com/entry/2013/11/10/180802
orient image orientation
http://www.imagemagick.org/script/command-line-options.php#orient
ImageMagickによる基本的な画像処理
http://www.gi.ce.t.kyoto-u.ac.jp/user/susaki/image/magick_process.html
iPhoneからアップロードしたJPEG写真が横向きになる問題(EXIF, Orientation)
https://qiita.com/RichardImaokaJP/items/385beb77eb39243e50a6
PHPでEXIFのOrientationを元に画像を回転 https://qiita.com/uda0922/items/c83c239eb32ed295fca8
// $input_imageには画像情報
$input_image;
// exif消す前にorientationだけ保持
$exif = exif_read_data($input_image);
$orientation = $exif['Orientation'];
$angle = 0;
if ($orientation == 3) {
$angle = 180;
} elseif ($orientation == 6) {
$angle = 90;
} elseif ($orientation == 8) {
$angle = -90;
} else {
$angle = 0;
}
// exifを削除
exec("convert -strip -rotate {$angle} $input_image $output_image");
-stripで余計やexifを削除している