Class: Storyboard::GifRenderer
- Defined in:
- lib/storyboard/generators/gif.rb
Instance Attribute Summary collapse
-
#dimensions ⇒ Object
Returns the value of attribute dimensions.
-
#pdf ⇒ Object
Returns the value of attribute pdf.
-
#storyboard ⇒ Object
Returns the value of attribute storyboard.
Instance Method Summary collapse
-
#initialize(parent) ⇒ GifRenderer
constructor
A new instance of GifRenderer.
- #render_frame(frame_name, subtitle = nil) ⇒ Object
- #set_dimensions(w, h) ⇒ Object
- #write ⇒ Object
Methods inherited from Renderer
Constructor Details
#initialize(parent) ⇒ GifRenderer
Returns a new instance of GifRenderer.
8 9 10 11 |
# File 'lib/storyboard/generators/gif.rb', line 8 def initialize(parent) @dimensions = [] @storyboard = parent end |
Instance Attribute Details
#dimensions ⇒ Object
Returns the value of attribute dimensions.
7 8 9 |
# File 'lib/storyboard/generators/gif.rb', line 7 def dimensions @dimensions end |
#pdf ⇒ Object
Returns the value of attribute pdf.
7 8 9 |
# File 'lib/storyboard/generators/gif.rb', line 7 def pdf @pdf end |
#storyboard ⇒ Object
Returns the value of attribute storyboard.
7 8 9 |
# File 'lib/storyboard/generators/gif.rb', line 7 def storyboard @storyboard end |
Instance Method Details
#render_frame(frame_name, subtitle = nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/storyboard/generators/gif.rb', line 22 def render_frame(frame_name, subtitle = nil) output_filename = File.join(@storyboard.[:save_directory], "sub-#{File.basename(frame_name)}") image = MiniMagick::Image.open(frame_name) if(@dimensions.empty?) resize_height = (image[:height] * (@storyboard.[:max_width].to_f/image[:width])).ceil set_dimensions(storyboard.[:max_width], resize_height) end image.resize "#{@dimensions[0]}x#{@dimensions[1]}" image.quality("60") self.add_subtitle(image, subtitle, @dimensions) if subtitle image.format 'jpeg' image.write(output_filename) image.destroy! end |
#set_dimensions(w, h) ⇒ Object
13 14 15 |
# File 'lib/storyboard/generators/gif.rb', line 13 def set_dimensions(w,h) @dimensions = [w,h] end |
#write ⇒ Object
17 18 19 20 |
# File 'lib/storyboard/generators/gif.rb', line 17 def write `cd #{@storyboard.[:save_directory]} && convert -coalesce -delay 10 -layers OptimizeTransparency -loop 0 -ordered-dither o8x8,8,8,4 +map sub-* "#{@storyboard.[:write_to]}/#{@storyboard.[:basename]}.gif"` LOG.info("Wrote #{@storyboard.[:write_to]}/#{@storyboard.[:basename]}.gif") end |