Class: Mugshot::Image
- Inherits:
-
Object
- Object
- Mugshot::Image
- Defined in:
- lib/mugshot/image.rb
Instance Method Summary collapse
- #background!(color) ⇒ Object
- #crop!(size) ⇒ Object
- #destroy! ⇒ Object
- #quality!(quality) ⇒ Object
- #resize!(size) ⇒ Object
- #to_blob(opts = {}) ⇒ Object
Instance Method Details
#background!(color) ⇒ Object
5 6 7 |
# File 'lib/mugshot/image.rb', line 5 def background!(color) @background_color = color end |
#crop!(size) ⇒ Object
20 21 22 23 24 |
# File 'lib/mugshot/image.rb', line 20 def crop!(size) w, h = parse_size(size) @image.resize_to_fill! w, h self end |
#destroy! ⇒ Object
31 32 33 34 |
# File 'lib/mugshot/image.rb', line 31 def destroy! @image.destroy! self end |
#quality!(quality) ⇒ Object
26 27 28 29 |
# File 'lib/mugshot/image.rb', line 26 def quality!(quality) @quality = quality.to_i self end |
#resize!(size) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/mugshot/image.rb', line 9 def resize!(size) w, h = parse_size(size) if [w, h].include?(nil) @image.resize_to_fit! w, h else @image.resize! w, h end self end |
#to_blob(opts = {}) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/mugshot/image.rb', line 36 def to_blob(opts = {}) opts.merge!(:quality => @quality) set_background(@background_color) if !!@background_color @image.strip! @image.to_blob do self.format = opts[:format].to_s if opts.include?(:format) self.quality = opts[:quality] if opts[:quality].present? end end |