I\'m building a script for image resizing in Symfony2.
As I\'d like to be able to use standard Symfony2 response system...
$headers = array(\'Content
Output buffering is probably the best solution.
BTW you can call one less function:
ob_start(); imagepng($img); $str = ob_get_clean();