Skip to content

Instantly share code, notes, and snippets.

@kuwabarahiroshi
Created December 16, 2016 14:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuwabarahiroshi/63ed391ec8d86cbf4a8e002e76d196f8 to your computer and use it in GitHub Desktop.
Save kuwabarahiroshi/63ed391ec8d86cbf4a8e002e76d196f8 to your computer and use it in GitHub Desktop.
Optimize CarrierWave images using image_optim
gem 'carrierwave'
gem 'image_optim_rails'
gem 'image_optim_pack'
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