Sha256: 507a1c6080471fdb1484af19bf2156c12f3b30aa39a555e2daf43a32e58e3d06
Contents?: true
Size: 1.3 KB
Versions: 4
Compression:
Stored size: 1.3 KB
Contents
module RetinaRails module Processors module CarrierWave extend ActiveSupport::Concern ## # Stores the original dimensions of the image as a serialized Hash in to the model # def store_retina_dimensions if model 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!( mounted_as => { version_name => { :width => width.to_i / 2, :height => height.to_i / 2 } } ) end end ## # Process retina quality of the image. # Works with ImageMagick and MiniMagick # # === Parameters # # [percentage (Int)] quality in percentage # def retina_quality(percentage) manipulate! do |img| if defined?(Magick) img.write(current_path) { self.quality = percentage } unless img.quality == percentage elsif defined?(MiniMagick) img.quality(percentage.to_s) end img = yield(img) if block_given? img end end end # CarrierWave end # Processors end # RetinaRails
Version data entries
4 entries across 4 versions & 1 rubygems