Class: Paperclip::SaveDimensions
- Inherits:
-
Processor
- Object
- Processor
- Paperclip::SaveDimensions
- Defined in:
- lib/retina_rails/processors/paperclip.rb
Instance Method Summary collapse
-
#make ⇒ Object
Stores the original dimensions of the image as a serialized Hash in to the model.
Instance Method Details
#make ⇒ Object
Stores the original dimensions of the image as a serialized Hash in to the model
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/retina_rails/processors/paperclip.rb', line 7 def make model = .instance file_path = file.path rescue nil style = [:style] if file_path width, height = `identify -format "%wx%h" '#{file_path}'`.split(/x/) ## Read dimensions ## Set original height and width attributes on model model.retina_dimensions = (model.retina_dimensions || {}).deep_merge!( .name => { style => { :width => width.to_i / 2, :height => height.to_i / 2 } } ) end file end |