Created
October 22, 2011 15:46
-
-
Save imonyse/1306127 to your computer and use it in GitHub Desktop.
Ruby script helps me convert paperclip handled file to 48x48 size, running under the avatars root directory.
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'fileutils' | |
def ignored_dir(name) | |
if name == '.' or name == '..' | |
return true | |
else | |
return false | |
end | |
end | |
Dir.foreach('.') do |d| | |
next if ignored_dir(d) | |
if File.directory? d | |
medium_dir = "#{d}/medium" | |
if !File.exists? medium_dir | |
FileUtils.mkdir medium_dir | |
end | |
original_dir = "#{d}/original" | |
Dir.foreach(original_dir) do |s| | |
next if ignored_dir(s) | |
`convert #{original_dir}/#{s} -resize 48x48 #{medium_dir}/#{s}` | |
puts "convert #{original_dir}/#{s} -resize 48x48 #{medium_dir}/#{s}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment