A simple port from http://perplexed.co.uk/1814_png_optimization_with_gd_library.htm to Symfony2