Sha256: 147ec5d79d95c0a3112418fb3fbdb73fd00bb24b7ed20d19b700a77b708bbf23
Contents?: true
Size: 786 Bytes
Versions: 2
Compression:
Stored size: 786 Bytes
Contents
module Paperclip class SaveDimensions < Paperclip::Processor ## # Stores the original dimensions of the image as a serialized Hash in to the model # def make model = attachment.instance file_path = file.path rescue nil style = options[: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!( attachment.name => { style => { :width => width.to_i / 2, :height => height.to_i / 2 } } ) end file end end # SaveDimensions end # Paperclip
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
retina_rails-2.0.1 | lib/retina_rails/processors/paperclip.rb |
retina_rails-2.0.0 | lib/retina_rails/processors/paperclip.rb |