Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Ruby
Pull request Compare This branch is 856 commits behind toy:master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
lib
spec
.gitignore
LICENSE.txt
README.markdown
TODO
image_optim.gemspec

README.markdown

image_optim

Optimize (lossless compress) images (jpeg, png, gif) using external utilities (advpng, gifsicle, jpegoptim, jpegtran, optipng, pngcrush, pngout).

Based on ImageOptim.app.

Gem Installation

gem install image_optim

Binaries Installation

Linux - Debian/Ubuntu

sudo apt-get install -y advancecomp gifsicle jpegoptim libjpeg-progs optipng pngcrush

Linux - RHEL/Fedora/Centos

sudo yum install -y advancecomp gifsicle libjpeg optipng

You will also need to install jpegoptim and pngcrush from source:

jpegoptim

cd /tmp
curl -O http://www.kokkonen.net/tjko/src/jpegoptim-1.2.4.tar.gz
tar zxf jpegoptim-1.2.4.tar.gz
cd jpegoptim-1.2.4
./configure && make && make install

pngcrush

cd /tmp
curl -O http://iweb.dl.sourceforge.net/project/pmt/pngcrush/1.7.24/pngcrush-1.7.24.tar.bz2
tar jxf pngcrush-1.7.24.tar.bz2
cd pngcrush-1.7.24
make && cp -f pngcrush /usr/local/bin

OS X - Macports

sudo port install advancecomp gifsicle jpegoptim jpeg optipng pngcrush

OS X - Brew

brew install advancecomp gifsicle jpegoptim jpeg optipng pngcrush

pngout Installation (optional)

You can install pngout by downloading and installing the binary versions.

Note: pngout is free to use even in commercial soft, but you can not redistribute, repackage or reuse it without consent and agreement of creator. license

Usage

In terminal:

image_optim *.{jpg,png,gif}

image_optim -h

Initilize optimizer (options are described in comments for ImageOptim, Worker and all workers):

io = ImageOptim.new

io = ImageOptim.new(:pngout => false)

io = ImageOptim.new(:nice => 20)

Optimize image getting temp path:

io.optimize_image('a.png')

Optimize image in place:

io.optimize_image!('b.jpg')

Multiple images:

io.optimize_images(Dir['*.png']) do |unoptimized, optimized|
  if optimized
    puts "#{unoptimized} => #{optimized}"
  end
end

io.optimize_images!(Dir['*.*'])

Copyright

Copyright (c) 2012 Ivan Kuchin. See LICENSE.txt for details.

Something went wrong with that request. Please try again.