自分の思ったような向きにならないことがあったのでメモ。
まずはImageMagickを使って -strip でExif削除するケースの場合。 削除後に見ると表示して欲しい方向とは違う感じで表示されてしまった。
$ $ identify -verbose hoge.jpg | grep Orientation Orientation: RightTop exif:Orientation: 6 $ $ convert hoge.jpg -strip hoge_after.jpg $ $ identify -verbose hoge_after.jpg | grep Orientation Orientation: Undefined $
次に -auto-orient を試してみた。 これが自分の望む動作になった。
$ $ mogrify -auto-orient hoge.jpg $ $ identify -verbose hoge.jpg | grep Orientation Orientation: TopLeft exif:Orientation: 1 $
リサイズで -thumbnail を使っているとexif情報は削除されるようだ。 実行してみたところ、生成された画像はやはり自分の希望する方向ではなかった。
$ $ convert hoge.jpg -thumbnail 640x640 hoge_thumb.jpg $ $ identify -verbose hoge_thumb.jpg | grep Orientation Orientation: Undefined $
リサイズで自分の欲しい向きにするには -auto-orient -resize の2つを使うのがいいみたい。 これで自分のやりたいことが出来た。
$ $ convert -auto-orient -resize 640x640 hoge.jpg hoge_resize.jpg $ $ identify -verbose hoge_resize.jpg | grep Orientation Orientation: TopLeft exif:Orientation: 1 $