Created
December 16, 2016 14:24
-
-
Save kuwabarahiroshi/63ed391ec8d86cbf4a8e002e76d196f8 to your computer and use it in GitHub Desktop.
Optimize CarrierWave images using image_optim
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
gem 'carrierwave' | |
gem 'image_optim_rails' | |
gem 'image_optim_pack' |
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 | |
process :optimize | |
def optimize | |
::ImageOptim.new(Rails.configuration.assets.image_optim) | |
.optimize_image!(current_path) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment