Class: LadyJosephine::BaseUploader
- Inherits:
-
CarrierWave::Uploader::Base
- Object
- CarrierWave::Uploader::Base
- LadyJosephine::BaseUploader
- Includes:
- CarrierWave::MiniMagick
- Defined in:
- app/uploader/lady_josephine/base_uploader.rb
Direct Known Subclasses
Instance Method Summary collapse
- #auto_orient ⇒ Object
- #compress_to_fill(width, height, percentage = 70) ⇒ Object
- #compress_to_fit(width, height, percentage = 70) ⇒ Object
- #store_dir ⇒ Object
- #strip ⇒ Object
Instance Method Details
#auto_orient ⇒ Object
24 25 26 27 28 |
# File 'app/uploader/lady_josephine/base_uploader.rb', line 24 def auto_orient manipulate! do |image| image.tap(&:auto_orient) end end |
#compress_to_fill(width, height, percentage = 70) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/uploader/lady_josephine/base_uploader.rb', line 47 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. do |c| c.quality(percentage.to_s) c.depth "8" c.interlace "plane" end end img = yield(img) if block_given? (img) img end end |
#compress_to_fit(width, height, percentage = 70) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/uploader/lady_josephine/base_uploader.rb', line 30 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. do |c| c.quality(percentage.to_s) c.depth "8" c.interlace "plane" end end img = yield(img) if block_given? (img) img end end |
#store_dir ⇒ Object
19 20 21 |
# File 'app/uploader/lady_josephine/base_uploader.rb', line 19 def store_dir "#{LadyJosephine.image_base_path}/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end |
#strip ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/uploader/lady_josephine/base_uploader.rb', line 11 def strip manipulate! do |img| img.strip img = yield(img) if block_given? img end end |