CwsImageOptimizer is a PHP class to optimize images. It uses optipng, pngout, pngcrush, advpng, advdef, jpegtran, jpegoptim, gifsicle and ImageMagick libraries and can combine one or more.