DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Resizing Images Using RMagick

01.18.2006
| 7186 views |
  • submit to reddit
        
require 'rubygems'
require 'RMagick'

include Magick

def append_filename(filename, suffix)
  extrac = filename.split('.')
  extrac[-2] += suffix
  extrac.join('.')
end                                                                                  
ARGV.each do |f|
  ImageList.new(f).resize(800, 600).write(append_filename(f, '_l'))
  ImageList.new(f).resize(400, 300).write(append_filename(f, '_m'))
  ImageList.new(f).resize(40, 30).write(append_filename(f, '_s'))
end
    

Comments

Snippets Manager replied on Thu, 2006/03/02 - 10:07pm

How do I tag this/