Class: C80AlbumGallery::GphotoUploader

Inherits:
BaseFileUploader
  • Object
show all
Includes:
CarrierWave::MiniMagick
Defined in:
app/uploaders/c80_album_gallery/gphoto_uploader.rb

Instance Method Summary collapse

Instance Method Details

#resize_to_lg(type = 'normal') ⇒ Object




50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'app/uploaders/c80_album_gallery/gphoto_uploader.rb', line 50

def resize_to_lg(type='normal')

  manipulate! do |img|

    w = C80AlbumGallery::Prop.first.thumb_lg_width
    h = C80AlbumGallery::Prop.first.thumb_lg_height

    img.resize "#{w}x#{h}^"
    img.gravity 'center'
    img.extent "#{w}x#{h}"

    if type == 'gray'
      img = img.colorspace 'Gray'
    end

    img = yield(img) if block_given?
    img

  end
  
end

#resize_to_md(type = 'normal') ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'app/uploaders/c80_album_gallery/gphoto_uploader.rb', line 72

def resize_to_md(type='normal')

  manipulate! do |img|

    w = C80AlbumGallery::Prop.first.thumb_md_width
    h = C80AlbumGallery::Prop.first.thumb_md_height

    img.resize "#{w}x#{h}^"
    img.gravity 'center'
    img.extent "#{w}x#{h}"

    if type == 'gray'
      img = img.colorspace 'gray'
    end

    img = yield(img) if block_given?
    img

  end

end

#resize_to_preview(type = 'normal') ⇒ Object



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'app/uploaders/c80_album_gallery/gphoto_uploader.rb', line 116

def resize_to_preview(type='normal')

  manipulate! do |img|

    w = C80AlbumGallery::Prop.first.thumb_preview_width
    h = C80AlbumGallery::Prop.first.thumb_preview_height

    img.resize "#{w}x#{h}^"
    img.gravity 'center'
    img.extent "#{w}x#{h}"

    if type == 'gray'
      img = img.colorspace 'gray'
    end

    img = yield(img) if block_given?
    img

  end

end

#resize_to_sm(type = 'normal') ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'app/uploaders/c80_album_gallery/gphoto_uploader.rb', line 94

def resize_to_sm(type='normal')

  manipulate! do |img|

    w = C80AlbumGallery::Prop.first.thumb_sm_width
    h = C80AlbumGallery::Prop.first.thumb_sm_height

    img.resize "#{w}x#{h}^"
    img.gravity 'center'
    img.extent "#{w}x#{h}"

    if type == 'gray'
      img = img.colorspace 'gray'
    end

    img = yield(img) if block_given?
    img

  end

end

#store_dirObject



9
10
11
# File 'app/uploaders/c80_album_gallery/gphoto_uploader.rb', line 9

def store_dir
  "uploads/gallery/#{format("%03d",model.gallery_id)}"
end