there are calls to
that are needless, since the image is already created you can just do this:
$fp = fopen($folder . $imagename, 'rb'); # stream the image directly from the cachefile
instead of reprocessing it thru GD. (this was taken from PHP.net here: http://php.net/manual/en/function.imagepng.php)
Also we had a bug where ob_start had previously been called. So we needed to clean the output buffer first.
this will clean out all the buffers:
$levels = ob_get_level();
for ($i=0; $i<$levels; $i++)