Parent

Class Index [+]

Quicksearch

ImageScience

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

Constants

VERSION

Public Class Methods

with_image(path) click to toggle source

The top-level image loader opens path and then yields the image.

    # File lib/image_science.rb, line 19
19:   def self.with_image(path) # :yields: image
20:   end
with_image_from_memory(data) click to toggle source

The top-level image loader, opens an image from the string data and then yields the image.

    # File lib/image_science.rb, line 25
25:   def self.with_image_from_memory(data) # :yields: image
26:   end

Public Instance Methods

cropped_thumbnail(size) click to toggle source

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
height() click to toggle source

Returns the height of the image, in pixels.

    # File lib/image_science.rb, line 43
43:   def height; end
resize(width, height) click to toggle source

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
save(path) click to toggle source

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
thumbnail(size) click to toggle source

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
width() click to toggle source

Returns the width of the image, in pixels.

    # File lib/image_science.rb, line 38
38:   def width; end
with_crop(left, top, right, bottom) click to toggle source

Crops an image to left, top, right, and bottom and then yields the new image.

    # File lib/image_science.rb, line 32
32:   def with_crop(left, top, right, bottom) # :yields: image
33:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.