Class: LgtmHD::MemeGenerator
- Inherits:
-
Object
- Object
- LgtmHD::MemeGenerator
- Defined in:
- lib/lgtm_hd.rb
Instance Attribute Summary collapse
-
#input_image_URI ⇒ Object
Returns the value of attribute input_image_URI.
-
#output_image_URI ⇒ Object
Returns the value of attribute output_image_URI.
Instance Method Summary collapse
-
#draw(caption_text = "LGTM") {|@img| ... } ⇒ MiniMagick::Image
Used to create a new Image object data-copy.
- #export {|@output_image_URI| ... } ⇒ Object
-
#initialize(input_image_URI, output_image_URI) ⇒ MemeGenerator
constructor
TODO make options list for this class TODO pass BLOB data into this class instead of paths.
Constructor Details
#initialize(input_image_URI, output_image_URI) ⇒ MemeGenerator
TODO make options list for this class TODO pass BLOB data into this class instead of paths
12 13 14 15 16 17 18 |
# File 'lib/lgtm_hd.rb', line 12 def initialize(input_image_URI, output_image_URI) @input_image_URI = input_image_URI @output_image_URI = output_image_URI @img = MiniMagick::Image.open(@input_image_URI) @caption_position = :caption_position_bottom end |
Instance Attribute Details
#input_image_URI ⇒ Object
Returns the value of attribute input_image_URI.
8 9 10 |
# File 'lib/lgtm_hd.rb', line 8 def input_image_URI @input_image_URI end |
#output_image_URI ⇒ Object
Returns the value of attribute output_image_URI.
8 9 10 |
# File 'lib/lgtm_hd.rb', line 8 def output_image_URI @output_image_URI end |
Instance Method Details
#draw(caption_text = "LGTM") {|@img| ... } ⇒ MiniMagick::Image
Used to create a new Image object data-copy. Not used to “paint” or that kind of thing.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/lgtm_hd.rb', line 27 def draw ( = "LGTM") if @img.respond_to? (:combine_options) then @img. do |c| c.gravity () c.draw "text 0,0 " << "#{}" c.font c.pointsize c.density imageDensity c.fill c.resize imageMaxSize().reduce() {|w,h| w << 'x' << h} # syntax: convert -resize $wx$h end @img.contrast end yield @img if block_given? end |
#export {|@output_image_URI| ... } ⇒ Object
43 44 45 46 |
# File 'lib/lgtm_hd.rb', line 43 def export @img.write(@output_image_URI) yield @output_image_URI if block_given? end |