image_compressor_for_carrierwave

On your CarrierWave uploader, include the extension:

class ImageUploader < CarrierWave::Uploader::Base
  ...
  include ImageCompressorForCarrierwave::CarrierWaveExtension
  ...
end

call the optimize method on the uploader:

class ImageUploader < CarrierWave::Uploader::Base
  ...
  process :optimize
  ...
end

passing parameters to encoders:

process optimize: [{ verbose: false, quality: 65, level: 2, command_options: '--strip all --i 1'}]