カレントディレクトリにある*.logファイルの拡張子を.txtに変更するサンプル 注
$ for i in *.log; do mv $i `basename -s .log $i`.txt; done
注 basenameコマンドに-sオプションを使うと末尾の文字列を削除できます。
カレントディレクトリにある*.logファイルの拡張子を.txtに変更するサンプル 注
$ for i in *.log; do mv $i `basename -s .log $i`.txt; done
注 basenameコマンドに-sオプションを使うと末尾の文字列を削除できます。
ImageMagickではデフォルトでアスペクト比を維持するようになっていますので、何もしなければアスペクト比が維持されます。
300px、縦はアスペクト比が変わらないようにリサイズ$ convert -resize 300x infile.jpg outfile.jpg
200px、横はアスペクト比が変わらないようにリサイズ$ convert -resize x200 infile.jpg outfile.jpg
300px、縦200px以下のサイズにリサイズ$ convert -resize 300x200 infile.jpg outfile.jpg
$ convert -resize 300x200^ infile.jpg outfile.jpg
アスペクト比を無視したい場合は!フラグを使います。
$ convert -resize 300x200! infile.jpg outfile.jpg
ファイルを上書きでサイズ変更したい場合はmodifyコマンドを使います。
$ mogrify -resize 300x200 file.jpg
画像をクロップ(トリミング)したい場合はcropコマンドを使います。
$ convert -gravity Center -crop 300x200+0+0 infile.png outfile.png
※切り取る位置を変更したい場合はCenterの代わりにNorth/South/East/Westなども使えます。
Resizing or Scaling — IM v6 Examples
https://legacy.imagemagick.org/Usage/resize/
Cutting and Bordering — IM v6 Examples
https://legacy.imagemagick.org/Usage/crop/