Skip to content

Instantly share code, notes, and snippets.

@fujidig
Created March 23, 2016 07:48
Show Gist options
  • Select an option

  • Save fujidig/b3e3ea055de8505d05f5 to your computer and use it in GitHub Desktop.

Select an option

Save fujidig/b3e3ea055de8505d05f5 to your computer and use it in GitHub Desktop.
# スキャンしたファイルを一括リサイズ&色補正
# カレントディレクトリにあるすべての.jpg(ただし名前に記号+がつかない)を編集し、
# 拡張子の前に+をつけて保存します
width = 824
gamma = 0.4
Dir.glob("*.jpg").each do |fname|
next if fname =~ /\+\.jpg$/
newname = fname.gsub(".jpg", "+.jpg")
system "convert", fname, "-resize", width.to_s, "-level", "0%,100%,#{gamma}", newname
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment