Gem Version Build Status Dependency Status

PaperclipOptimizer is a processor for Paperclip that allows you to optimize and minify uploaded JPG, PNG or GIF images.

It is just a thin wrapper around ImageOptim, which supports many external optimization libraries like

What’s new

2014-05-02 1.0.3 released

  • updated tests, compatibility with Paperclip 4 - thanks Sija

2014-04-02 1.0.2 released

  • relax Paperclip dependency, allow 3.4.x again since it works fine

Read the CHANGELOG for previous changes.


PaperclipOptimizer is currently compatible with Paperclip 3.4.0 to 4.1.x.


Add this line to your application’s Gemfile after the Paperclip gem:

gem 'paperclip-optimizer'

And then execute:

$ bundle

See ImageOptims README on how to install the various optimization libraries.

Deployment on Heroku

If you deploy to Heroku, take a look at the image_optim_bin gem. It supplies the necessary optimization binaries, compiled and ready for Herokus environment.

gem "image_optim_bin", group: :production
gem "paperclip-optimizer"


Just add :paperclip_optimizer to Paperclips :processors - setting:

ruby class User < ActiveRecord::Base attr_accessible :avatar has_attached_file :avatar, :styles => { :thumb => "100x100>" }, :default_url => "/images/:style/missing.png", :processors => [:thumbnail, :paperclip_optimizer] end

Remember to include the :thumbnail processor as well if you want to retain Paperclips geometry functionality.


By default, PaperclipOptimizer only enables jpegtran and optipng. You can pass configuration options to ImageOptim through the :styles hash:

ruby class User < ActiveRecord::Base attr_accessible :avatar has_attached_file :avatar, :styles => { :thumb => { :geometry => "100x100>", :paperclip_optimizer => { :pngout => { :strategy => 1 } } } }, :default_url => "/images/:style/missing.png", :processors => [:thumbnail, :paperclip_optimizer] end

See ImageOptims options for all available options.


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request