Class: AmpleAssets::CustomProcessor
- Inherits:
-
Object
- Object
- AmpleAssets::CustomProcessor
- Includes:
- Dragonfly::Configurable, Dragonfly::ImageMagick::Utils
- Defined in:
- lib/ample_assets/custom_processor.rb
Instance Method Summary collapse
Instance Method Details
#matte(temp_object, args = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/ample_assets/custom_processor.rb', line 7 def matte(temp_object, args={}) opts = { :background => 'transparent', :gravity => 'Center', :dimensions => '100x100' }.merge(args) raise "Geometry of #{opts[:dimensions]} not supported for matte images" unless opts[:dimensions][/^(\d+)x(\d+)$/] convert(temp_object, "-gravity #{opts[:gravity]} -resize #{opts[:dimensions]}^> -crop #{opts[:dimensions]}+0+0>\! -background #{opts[:background]} -flatten") end |
#play_button(temp_object) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ample_assets/custom_processor.rb', line 17 def (temp_object) attrs = identify(temp_object) # hardcoded for convenience icon_size = 500.to_f shortest_edge = [attrs[:width], attrs[:height]].max.to_f scale = (shortest_edge / 3) / icon_size final_icon_size = (scale * icon_size).to_i geometry = "#{final_icon_size}x#{final_icon_size}+#{(attrs[:width]/2)-(final_icon_size/2)}+#{(attrs[:height]/2)-(final_icon_size/2)}" convert(temp_object, "#{AmpleAssets::Engine.root}/app/assets/images/ample_assets/play.png -geometry #{geometry} -composite") end |