forked from bofh/fetsite
ADD: quality-process added to FotoUploader
This commit is contained in:
@@ -34,9 +34,11 @@ class FotoUploader < CarrierWave::Uploader::Base
|
|||||||
# Create different versions of your uploaded files:
|
# Create different versions of your uploaded files:
|
||||||
version :thumb do
|
version :thumb do
|
||||||
process :resize_to_fill => [64, 64]
|
process :resize_to_fill => [64, 64]
|
||||||
|
process :quality => 30
|
||||||
end
|
end
|
||||||
version :big_thumb do
|
version :big_thumb do
|
||||||
process :resize_to_fill => [128, 128]
|
process :resize_to_fill => [128, 128]
|
||||||
|
process :quality => 30
|
||||||
end
|
end
|
||||||
version :resized do
|
version :resized do
|
||||||
process :resize_to_fit => [1024, 1024]
|
process :resize_to_fit => [1024, 1024]
|
||||||
@@ -53,4 +55,5 @@ class FotoUploader < CarrierWave::Uploader::Base
|
|||||||
# "something.jpg" if original_filename
|
# "something.jpg" if original_filename
|
||||||
# end
|
# end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
13
config/initializers/carrierwave.rb
Normal file
13
config/initializers/carrierwave.rb
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
module CarrierWave
|
||||||
|
module RMagick
|
||||||
|
|
||||||
|
def quality(percentage)
|
||||||
|
manipulate! do |img|
|
||||||
|
img.write(current_path){ self.quality = percentage } unless img.quality == percentage
|
||||||
|
img = yield(img) if block_given?
|
||||||
|
img
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user