参考
- http://www5a.biglobe.ne.jp/~nkgwtty/njaLinuxImageMagick.html
- http://hashi4.civil.tohoku.ac.jp/soft/node43.html
コマンドはこんな感じ
$ convert before.jpg -background "#e2ddd4" -gravity north -splice 0x10 after.jpg
まとめ
- spliceに与える引数は、「width」x「height」
- gravityは、northwest,north,northeast,west,center,east,southwest,south,southeast の値をとれる
- この二つのオプションの相関は下記の通り
width | height | |
---|---|---|
northwest | 右 | 上 |
north | 真ん中 | 上 |
northeast | 右 | 上 |
west | 左 | 真ん中 |
center | 真ん中 | 真ん中 |
east | 右 | 真ん中 |
southwest | 左 | 下 |
south | 真ん中 | 下 |
southeast | 右 | 下 |
やりたかったのは・・・
実は左右に余白を入れたかったのだけど、どうも無いみたい。2回Convertかませれば行けるけど。
で、見つけたのは、frameオプション+mattecolorオプション。オプションの引数の順序は下記のように順番があるみたい。このページのはダメだった。
$convert sample.jpg -geometry 577x389 -mattecolor "#ffffff" -frame 0x80 sample_c.jpg
ちなみに
frameもspliceもgeometryの後に操作する。つまり、正方形にしたかったらframeを足して正方形になるようなgeometryにする必要がある。