幅が高さより大きい場合、画像の回転

幅が高さより大きい場合、画像の回転

サイズの異なる何千もの長方形の画像があります。私は両方の幅よりも背の高いサイズが欲しい。高さが幅より小さいすべての画像を90度回転してこれを達成したいと思います。 imagemagickを使ってどうすればこれを行うことができますか?

ベストアンサー1

画像の幅と高さを取得してw> hであることを確認してから、回転させる以下の簡単な関数を作成できます。

rotate() {
    (( $(identify -format '%w > %h' "$1") )) && convert "$1" -rotate 90 "rotated_$1"; 
}

呼びなさいrotate image.png


別の方法はユーザー 414777使用エキシプツール、つまりベースEXIF方向タグ:

exif -co rotated_"$1" --ifd=0 --tag=0x0112 --set-value=6 "$1"

スイッチの説明:

TagID    TagName       Writable  Group   Values/Notes
0x0112   Orientation   int16u    IFD0    1 = Horizontal (normal)
                                         2 = Mirror horizontal
                                         3 = Rotate 180
                                         4 = Mirror vertical
                                         5 = Mirror horizontal and rotate 270 CW
                                         6 = Rotate 90 CW
                                         7 = Mirror horizontal and rotate 90 CW
                                         8 = Rotate 270 CW

おすすめ記事