Image Optimizer
Image Optimizer optimizes given JPEG and PNG images or images in given folder. Performs the following for PNG:
- rewrites PNG file using
convert
, - optimizes it using
optipng
.
And for JPEG:
- strips all unnecessary metadata using
jpegoptim
, - 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:
- UNIX-like system (required),
- Ruby (required),
- whereis (required),
- ImageMagick,
- Jpegtran,
- Jpegoptim,
- OptiPNG.
Steps which requires non-strictly required components will be silently ignored if these components will not be available.
Contributing
- Fork it.
- Create a branch (
git checkout -b 20101220-my-change
). - Commit your changes (
git commit -am "Added something"
). - Push to the branch (
git push origin 20101220-my-change
). - Create an Issue with a link to your branch.
- Enjoy a refreshing Diet Coke and wait.
Copyright
Copyright © 2011 Martin Kozák. See LICENSE.txt
for
further details.