Sha256: 561d610bf058eb6ac57c17bad7707aa4856d5d10856b2612fd9d629ac78b8b0e
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
require 'carrierwave' module LadyJosephine class BaseUploader < ::CarrierWave::Uploader::Base include ::CarrierWave::MiniMagick storage :file process :auto_orient def strip manipulate! do |img| img.strip img = yield(img) if block_given? img end end def store_dir "#{LadyJosephine.image_base_path}/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end # https://makandracards.com/makandra/12323-carrierwave-auto-rotate-tagged-jpegs def auto_orient manipulate! do |image| image.tap(&:auto_orient) end end def compress_to_fit(width, height, percentage = 70) manipulate! do |img| img.resize "#{width}x#{height}" if img.mime_type.match(/(png|jpeg|jpg)\z/i) img.combine_options do |c| c.quality(percentage.to_s) c.depth "8" c.interlace "plane" end end img = yield(img) if block_given? add_metadata(img) img end end def compress_to_fill(width, height, percentage = 70) manipulate! do |img| img.resize "#{width}x#{height}^" img.gravity "center" img.crop "#{width}x#{height}+0+0!" if img.mime_type.match(/(png|jpeg|jpg)\z/i) img.combine_options do |c| c.quality(percentage.to_s) c.depth "8" c.interlace "plane" end end img = yield(img) if block_given? add_metadata(img) img end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lady_josephine-0.7.0 | app/uploader/lady_josephine/base_uploader.rb |