FastImage Resize is an extremely light solution for resizing images in ruby by using libgd
FastImage Resize will resize gifs, jpegs, and png files.
It uses resampling to get good looking results.
And it doesn’t rely on installing external heavy libraries such as RMagick (which relies on ImageMagick or GraphicsMagick) or ImageScience (which relies on FreeImage).
require 'fastimage_resize' FastImage.resize("http://stephensykes.com/images/ss.com_x.gif", "my.gif", 100, 20) => 1
The file my.gif is created locally, containing the resized image.
First check the requirements section below.
sudo gem install sdsykes-fastimage_resize -s http://gems.github.com
Install the gem as above, and configure it in your environment.rb file as below:
... Rails::Initializer.run do |config| ... config.gem "sdsykes-fastimage_resize", :lib=>"fastimage_resize" ... end ...
You may also need this in your environment.rb so that the rails process puts the compiled C code in a place it can access:
ENV['INLINEDIR'] = RAILS_ROOT + "/tmp" # for RubyInline
Then you’re off – just use FastImage.resize() in your code as in the examples.
sudo gem install RubyInline
sudo gem install sdsykes-fastimage -s http://gems.github.com
Libgd is commonly available on most unix platforms, including OSX.
Because of the way that libgd works, gif files that have transparency may not always come through with the transparency perfectly retained.
You’ll need to ‘sudo gem install fakeweb’ to be able to run the tests