Jpegtran

Provides Ruby interface to the jpegtran tool.

Travis CI

Installation

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.

Usage

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.

Configuring

Jpegtran.configure do |config|
  config.executable = "/usr/local/bin/jpegtran"
end

Copyright © 2011 – 2016 Martin Poljak