Provides Ruby interface to the jpegtran tool.
Add this line to your application's Gemfile:
gem 'jpegtran-ruby'
And then execute:
$ bundle
Or install it yourself as:
$ gem install jpegtran-ruby
This gem uses jpegtran
executable. So it needs to be installed on the machine.
Usually it comes with the libjpeg or you can use MozJPEG.
require "jpegtran"
Jpegtran.configured? # will return true (or false)
options = { progressive: true, optimize: true }
Jpegtran.optimize("foo.jpg", options) # will run `jpegtran -progressive -optimize -outfile foo.jpg foo.jpg`
Note that -maxmemory N
option isn't supported.
Jpegtran.configure do |config|
config.executable = "/usr/local/bin/jpegtran"
end
Copyright © 2011 – 2016 Martin Poljak