Skip to content

Instantly share code, notes, and snippets.

@oscarmcm
Last active December 31, 2015 16:49
Show Gist options
  • Save oscarmcm/8016228 to your computer and use it in GitHub Desktop.
Save oscarmcm/8016228 to your computer and use it in GitHub Desktop.
Reduce el tamao de la imagenes
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