Image Optimizer

Image Optimizer optimizes given JPEG and PNG images or images in given folder. Performs the following for PNG:

  1. rewrites PNG file using convert,
  2. optimizes it using optipng.

And for JPEG:

  1. strips all unnecessary metadata using jpegoptim,
  2. optimizes using jpegtran.

Usage

Simply both for files or whole directories:

ImageOptimizer::optimize("./some-dir", :strip => false, :level => 7) do |file|
    p file    # prints out target filename
end

Where :strip option indicates it should strip all metadata from JPEG files. Default is true. :level indicates level of PNG optimization. Default is 7.

For command line usage see help for the image-optimizer command.

Requirements

Following software for full functionality is necessary:

Steps which requires non-strictly required components will be silently ignored if these components will not be available.

Contributing

  1. Fork it.
  2. Create a branch (git checkout -b 20101220-my-change).
  3. Commit your changes (git commit -am "Added something").
  4. Push to the branch (git push origin 20101220-my-change).
  5. Create an Issue with a link to your branch.
  6. Enjoy a refreshing Diet Coke and wait.

Copyright © 2011 Martin Kozák. See LICENSE.txt for further details.