Class: LadyJosephine::BaseUploader

Inherits:
CarrierWave::Uploader::Base
  • Object
show all
Includes:
CarrierWave::MiniMagick
Defined in:
app/uploader/lady_josephine/base_uploader.rb

Direct Known Subclasses

ImageUploader

Instance Method Summary collapse

Instance Method Details

#auto_orientObject



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.combine_options 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.combine_options 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_dirObject



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

#stripObject



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