www.cleverleap.com

Ruby on Rails thumbnail generator

Would you like to instantly generate thumbnails of any size?

Ruby thumbnail generator is a simple script which is ideal to use in your Ruby on Rails application to quickly generate thumbnails of any proportions. Just set width and height and get image.

Features
  • support for JPEG, PNG and GIF formats
  • custom width and height (set ?w=250&h=300 in pixels in the URL)
  • calculate proper proportions
  • cache resized images
Download it here

Installation:

1. copy "thumb_controller.rb" into your /controllers/ directory

2. edit /config/routes.rb and add this line:
map.connect "thumb/*specs", :controller => "thumb", :action => "index"

3. create directory /imagelib/ in RoR's /public/ directory and
/image_cache/ inside /imagelib/ directoory

Now you can call /thumb/photo.jpg?w=400&h=350 and you will
see resized picture "photo.jpg". photo.jpg should be stored in
/public/imagelib/ directory. Off course you can change directory
structure if you wish just don't forget to edit thumb_controller.rb
than.

Requirements

Ruby/GD2 and Thomas Boutell's GD 2 graphics library

Tip:

Instead of CGI you can use:
send_file(cachedpicfile, :type => 'image/jpeg', :disposition => 'inline') and delete render :nothing => true
by Simone Romano

Comments / Discussion

Here you can post comments or suggest improvements.
Name: Date: Subject:

We develop for the iPhone

Discover power of web based applications. Access your data anywhere, on your PC or the iPhone, in the office or while on the trip.
We develop for the iPhone

Get a free bootstrapping edition of CMS

Are you a start-up looking for a content management system or a new website? As we too are starting now, we understand your needs perfectly. If you are about to set up your first web site you will get "typevista" CMS solution for free. If you have a web site already you will pay only the cost of integration. Take advantage of this great offer - we want to help you succeed in your new venture!
Try DEMO - it is easy