Created
July 1, 2011 12:50
-
-
Save a-chernykh/1058477 to your computer and use it in GitHub Desktop.
Change image quality with carrierwave and mini_magick
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# put this in config/initializers/carrierwave.rb | |
module CarrierWave | |
module MiniMagick | |
def quality(percentage) | |
manipulate! do |img| | |
img.quality(percentage) | |
img = yield(img) if block_given? | |
img | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ImageUploader < CarrierWave::Uploader::Base | |
include CarrierWave::MiniMagick | |
process :quality => 85 | |
version :medium do | |
process :quality => 85 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cool! Thanks for this example.