This gem allows you to optimize CarrierWave images using the image_optim gem.
Add this line to your application's Gemfile:
gem 'carrierwave-imageoptim'
And then execute:
$ bundle
Or install it yourself as:
$ gem install carrierwave-imageoptim
To add image optimization to your CarrierWave uploader, first include the module:
class MyUploader < CarrierWave::Uploader::Base
include CarrierWave::ImageOptim
...
end
Then apply to all versions via:
class MyUploader < CarrierWave::Uploader::Base
include CarrierWave::ImageOptim
process optimize: [{
jpegoptim: true,
optipng: true,
gifsicle: true
}]
end
Or to a single image version via:
class MyUploader < CarrierWave::Uploader::Base
include CarrierWave::ImageOptim
version :thumbnail do
process optimize: [{
jpegoptim: true,
optipng: true,
gifsicle: true
}]
end
end
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request