Object
Provides a clean and simple API to generate thumbnails using FreeImage as the underlying mechanism.
For more information or if you have build issues with FreeImage, see seattlerb.rubyforge.org/ImageScience.html
Creates a square thumbnail of the image cropping the longest edge to match the shortest edge, resizes to size, and yields the new image.
# File lib/image_science.rb, line 76
76: def cropped_thumbnail(size) # :yields: image
77: w, h = width, height
78: l, t, r, b, half = 0, 0, w, h, (w - h).abs / 2
79:
80: l, r = half, half + h if w > h
81: t, b = half, half + w if h > w
82:
83: with_crop(l, t, r, b) do |img|
84: img.thumbnail(size) do |thumb|
85: yield thumb
86: end
87: end
88: end
Returns the height of the image, in pixels.
# File lib/image_science.rb, line 43
43: def height; end
Resizes the image to width and height using a cubic-bspline filter and yields the new image.
# File lib/image_science.rb, line 55
55: def resize(width, height) # :yields: image
56: end
Saves the image out to path. Changing the file extension will convert the file type to the appropriate format.
# File lib/image_science.rb, line 49
49: def save(path); end
Creates a proportional thumbnail of the image scaled so its longest edge is resized to size and yields the new image.
# File lib/image_science.rb, line 62
62: def thumbnail(size) # :yields: image
63: w, h = width, height
64: scale = size.to_f / (w > h ? w : h)
65:
66: self.resize((w * scale).to_i, (h * scale).to_i) do |image|
67: yield image
68: end
69: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.