Created
July 26, 2011 18:23
-
-
Save kurko/1107437 to your computer and use it in GitHub Desktop.
Small script for resizing and saving (caching) images inside a directory
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 'mini_magick' | |
suffix = "cached_" | |
sleep_between_process = 0.3 | |
sizes = ["x142","x200"] | |
# loop through files | |
Dir.glob("[^cache]*").each { |e| | |
image_path = File.expand_path(e) | |
image = MiniMagick::Image.open(image_path) | |
sizes.each { |size| | |
image.resize(size) | |
image.write suffix+size+"_"+e | |
sleep(sleep_between_process) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment