This gem allows you to simply optimize images via jpegoptim or optipng.