This old script uses various image compression techniques to get the best lossless compressed image.
$ grind image.png
You must have the mime-types gem installed.
$ sudo gem install mime-types
You must have optipng and pngout in your PATH. If you’re on a Mac, you can install both with Homebrew.
$ brew install optipng
$ brew install https://raw.github.com/cbguder/homebrew/53ea33bab5372ea74117ace8c44aa7ea988e93c2/Library/Formula/pngout.rb