This repository contains the ruby library which adds file processor to compress JPEG images uploaded using the paperclip and kt-paperclip gem.
Add this line to your application's Gemfile:
gem 'paperclip-mozjpeg'
# or
gem 'kt-paperclip-mozjpeg'
# To use bundled binaries of MozJPEG 3.0 for Mac OS X, Linux and Windows add:
gem 'mozjpeg'
And then execute:
$ bundle
Or install it yourself as:
$ gem install paperclip-mozjpeg
# or
$ gem install kt-paperclip-mozjpeg
To install bundled binaries (must require 'mozjpeg'
if not using bundler):
$ gem install mozjpeg
class User < ActiveRecord::Base
has_attached_file :avatar, :styles => {
:tiny => {
geometry: '190x190>',
mozjpeg_options: '-quality 30',
},
:large => {
geometry: '1280x1280>',
mozjpeg_options: '-quality 70 -quant-table 2 -notrellis',
}
},
processors: [ :thumbnail, :mozjpeg ]
end
If you don't want to use the mozjpeg
gem bundled binaries and want to specify the path to mozjpeg (cjpeg) or it is not in the PATH
use the mozjpeg_path
option.
This gem is licensed under the MIT license.
- Fork it ( https://github.com/svoboda-jan/paperclip-mozjpeg/fork )
- 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 a new Pull Request