Class: Teaas::Turboize
- Inherits:
-
Object
- Object
- Teaas::Turboize
- Defined in:
- lib/teaas/turboize.rb
Class Method Summary collapse
-
.turbo(img, resize, speeds = [2, 5, 10, 20, 30, 40], options = {}) ⇒ Array
Takes in an image, a resize parameter, and optionally speeds, and returns an image or images that are sped up or slowed down.
-
.turbo_from_file(path, resize, speeds = [2, 5, 10, 20, 30, 40], options = {}) ⇒ Array
Takes in a path to an image, a resize parameter, and optionally speeds, and returns an image or images that are sped up or slowed down.
-
.turboize_individual_image(img, turbo, options = {}) ⇒ Magick::ImageList
Takes in a ‘Magick::ImageList` and adjusts the GIF image delay, ticks per second, and iterations.
Class Method Details
.turbo(img, resize, speeds = [2, 5, 10, 20, 30, 40], options = {}) ⇒ Array
Takes in an image, a resize parameter, and optionally speeds, and returns an image or images that are sped up or slowed down.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/teaas/turboize.rb', line 10 def self.turbo(img, resize, speeds=[2, 5, 10, 20, 30, 40], ={}) speeds = [2, 5, 10, 20, 30, 40] if speeds.nil? if !resize.nil? && !resize.empty? img = Teaas::Resize.resize(img, resize, ) end image_blobs = [] speeds.each do |turbo| image_blobs << turboize_individual_image(img, turbo, ).to_blob end image_blobs end |
.turbo_from_file(path, resize, speeds = [2, 5, 10, 20, 30, 40], options = {}) ⇒ Array
Takes in a path to an image, a resize parameter, and optionally speeds, and returns an image or images that are sped up or slowed down. This method is just a wrapper around turbo
30 31 32 33 34 35 |
# File 'lib/teaas/turboize.rb', line 30 def self.turbo_from_file(path, resize, speeds=[2, 5, 10, 20, 30, 40], ={}) img = Magick::ImageList.new img.read(path) turbo(img, resize, speeds, ) end |
.turboize_individual_image(img, turbo, options = {}) ⇒ Magick::ImageList
Takes in a ‘Magick::ImageList` and adjusts the GIF image delay, ticks per second, and iterations.
42 43 44 45 46 47 |
# File 'lib/teaas/turboize.rb', line 42 def self.turboize_individual_image(img, turbo, ={}) img.delay = [:delay] || 1 img.ticks_per_second = turbo img.iterations = 0 img end |