LoginSignup
0
0

More than 5 years have passed since last update.

ImageMagickを使って画像のキャンバスサイズを拡大する

Posted at
  • 指示内容を画像上に書くのに右側に余白がほしい
  • だけど画像数(ページ数)が多すぎていちいちmspaintなどで作業するのはメンドクサイ

めんどくさいことはワンライナーで解決しよう

$ cd IMG_DIR
## findのオプションは、適宜調整。今回はpngファイル
$ find . -type f -name -name \*.png -exec convert {} -gravity west -background white -extent 1200x0 {} \;

解説

コマンド単品だとconvert INPUT_FILENAME -gravity west -background white -extent WIDTHxHEIGHT OUTPUT_FILENAME

  • extentオプションでキャンパスを拡大
    • WIDTHには、現状の横幅+必要な横幅の値(e.g. 横幅800pxの画像に400pxの余白がほしければ、1200px)
    • HEIGHTには、0を指定することで、INPUTの画像の縦幅と同じになる
  • gravityオプションでwestを指定することで左寄せになる。
  • backgroundオプションは見たまんまです。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0