Created
February 2, 2011 14:50
-
-
Save amardaxini/807784 to your computer and use it in GitHub Desktop.
resize image using gd2 or generate thumbnail of image
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 'gd2-ffij' | |
class Thumbnail | |
include GD2 | |
def self.thumb(file_name,thumb_name,resized_width=100,resized_height=100,options={}) | |
#import image | |
image = Image.import(file_name) | |
#resize image by passing width and height | |
resize_image = image.resize(resized_width, resized_height,true) | |
# export an image to desired file format | |
resize_image.export(thumb_name,options) | |
end | |
end | |
Thumbnail.thumb('test.jpg','thumb1.png',200,300) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment