public
Created — forked from mariovisic/avatar_uploader.rb

  • Download Gist
avatar_uploader.rb
Ruby
1 2 3 4 5 6
# app/uploaders/avatar_uploader.rb
 
process :fix_exif_rotation
process :strip
process :resize_to_fill => [1024, 768]
process :quality => 90 # Percentage from 0 - 100
carrierwave_initializer.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
# config/initializers/carrierwave_initializer.rb
 
module CarrierWave
module RMagick
 
# Rotates the image based on the EXIF Orientation
def fix_exif_rotation
manipulate! do |img|
img.auto_orient!
img = yield(img) if block_given?
img
end
end
 
# Strips out all embedded information from the image
def strip
manipulate! do |img|
img.strip!
img = yield(img) if block_given?
img
end
end
 
# Reduces the quality of the image to the percentage given
def quality(percentage)
manipulate! do |img|
img.write(current_path){ self.quality = percentage }
img = yield(img) if block_given?
img
end
end
 
end
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.