LoginSignup
1
3

More than 5 years have passed since last update.

bash / ImageMagick > 画像の端を切りながらファイル形式の変換 > bashスクリプト

Last updated at Posted at 2016-11-10
動作環境
CentOS 6.8
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
Version: ImageMagick 6.7.2-7 2016-06-16 Q16 http://www.imagemagick.org

作成したpsファイルに対して以下をしたい。

  • pngファイルに変換する
  • 上下左右の余分な領域をカット
#!/usr/bin/env bash

fmt='s/\.ps/\.png/g'

for dd in $(ls *.ps);do
    newfile=$(echo $dd | sed $fmt)
    convert -crop 430x360+50+350 $dd $newfile
    echo $newfile
#   break; # for debug
done
結果
$ bash conv_exec

上記でそのフォルダにあるpsファイルすべてをpngに変換する。

切り取り領域の指定(430x360+50+350)は実際にconvertをしながら目視調整した。

変換が終わったファイルに関しては以下で確認した。

  • eog *.png
  • Spaceを連打
    • アニメーション表示
1
3
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
1
3