Skip to content

Instantly share code, notes, and snippets.

@tgck
Last active May 4, 2017 17:29
Show Gist options
  • Save tgck/91c3496550c2cfbf61a68ef5627189bf to your computer and use it in GitHub Desktop.
Save tgck/91c3496550c2cfbf61a68ef5627189bf to your computer and use it in GitHub Desktop.
複数のファイルを一括でcropする(image magick)
# そもそもやりたいこと
convert "sc 2017-05-04 at 21.54.14.png" -crop 1920x1480+360+0 out.png
# 参考 [画像のサイズ変更(切り抜き・塗足し etc.)](http://imagemagick.rulez.jp/archives/550)
# リネーム(ファイル名から空白除去)
for FILE in *; do mv "$FILE" ${FILE// /_}; done
# 画像をcrop
for f in `ls` ; do
convert $f -crop 1920x1480+360+0 out/${f}
done;
##
# ファイル名を改変
# bef: 048-128_at_23.43.52.png
# aft: 128x048_at_23.43.52.png
for f in `ls *png` ; do
mv $f `echo $f | sed -e "s/\([0-9]*\)-\([0-9]*\)\(.*png\)/\2x\1\3/"`;
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment