Last active
December 31, 2015 16:49
-
-
Save oscarmcm/8016228 to your computer and use it in GitHub Desktop.
Reduce el tamao de la imagenes
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' | |
# get the folder containing the original images | |
folder = ARGV[0] | |
# reduce by 35% = 35/100 | |
scale_by = 0.35 | |
# Get the images in the folder | |
# (you may replace JPG for whatever extension you will be processing ) | |
files = Dir.glob("#{folder}/*.JPG") do |f| | |
# read the image | |
image = Magick::Image.read(f).first | |
# scale the images | |
puts "resizing #{image.filename}" | |
new_image = image.scale(scale_by) | |
new_image.write("resized/#{image.filename}") | |
# sleep(5) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment