Last active
December 17, 2015 21:29
-
-
Save hiroism007/5675240 to your computer and use it in GitHub Desktop.
画像ぼかしwith Rmagick
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
カレントディレクトリ以下のフォルダーを走査し画像がある場合、カレントディレクトリにRmagickの処理をした新しい画像を生成するスクリプト