<commit_before># image_optim

Optimize (lossless compress) images (jpeg, png, gif) using external utilities:

* [advpng](http://advancemame.sourceforge.net/doc-advpng.html) from [AdvanceCOMP](http://advancemame.sourceforge.net/comp-readme.html)
* [gifsicle](http://www.lcdf.org/gifsicle/)
* [jpegoptim](http://www.kokkonen.net/tjko/projects.html)
* jpegtran from [Independent JPEG Group's JPEG library](http://www.ijg.org/)
* [optipng](http://optipng.sourceforge.net/)
* [pngcrush](http://pmt.sourceforge.net/pngcrush/)
* [pngout](http://www.advsys.net/ken/util/pngout.htm)

Based on [ImageOptim.app](http://imageoptim.com/).

## 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](http://www.jonof.id.au/kenutils).

_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](http://advsys.net/ken/utils.htm#pngoutkziplicense)_

## Usage

In terminal:

    image_optim *.{jpg,png,gif}

    image_optim -h

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

    image_optim = ImageOptim.new

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

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

Optimize image getting temp path:<commit_msg>added usage sub-headers to README<commit_after># image_optim

Optimize (lossless compress) images (jpeg, png, gif) using external utilities:

* [advpng](http://advancemame.sourceforge.net/doc-advpng.html) from [AdvanceCOMP](http://advancemame.sourceforge.net/comp-readme.html)
* [gifsicle](http://www.lcdf.org/gifsicle/)
* [jpegoptim](http://www.kokkonen.net/tjko/projects.html)
* jpegtran from [Independent JPEG Group's JPEG library](http://www.ijg.org/)
* [optipng](http://optipng.sourceforge.net/)
* [pngcrush](http://pmt.sourceforge.net/pngcrush/)
* [pngout](http://www.advsys.net/ken/util/pngout.htm)

Based on [ImageOptim.app](http://imageoptim.com/).

## 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](http://www.jonof.id.au/kenutils).

_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](http://advsys.net/ken/utils.htm#pngoutkziplicense)_

## Usage

### From shell

    image_optim *.{jpg,png,gif}

    image_optim -h

### From ruby

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

    image_optim = ImageOptim.new

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

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

Optimize image getting temp path:
{'fraction_non_alphanumeric': 0.12594349795126158, 'fraction_numerical': 0.012508087125296528, 'mean_word_length': 3.796277145811789, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 12, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '603206', 'n_tokens_mistral': 1728, 'n_tokens_neox': 1596, 'n_words': 399}