Skip to content

Instantly share code, notes, and snippets.

@hiroism007
Last active December 17, 2015 21:29
Show Gist options
  • Save hiroism007/5675240 to your computer and use it in GitHub Desktop.
Save hiroism007/5675240 to your computer and use it in GitHub Desktop.
画像ぼかしwith Rmagick
require "rubygems"
require "rmagick"
def directory_search(path)
list = Dir.glob("#{path}/*")
list.each_with_index do |child, index|
if File.directory?(child)
directory_search(child)
else
if File.extname(child) =~ /(jpg)|(png)/
img = Magick::ImageList.new("#{child}")
img.blur_image(radius=30,sigma=30).write("new_photo_#{index}.png")
end
end
end
end
if __FILE__ == $0
path = File.expand_path(File.dirname($0))
directory_search(path)
end
@hiroism007
Copy link
Author

カレントディレクトリ以下のフォルダーを走査し画像がある場合、カレントディレクトリにRmagickの処理をした新しい画像を生成するスクリプト

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment