In the PHP manual for base64_encode() I saw the following script for outputting an image.
Ok, sorry, I was thinking too fast :)
imagepng()
will output raw data stream directly to the browser, so you must use ob_start()
and other output buffering handles to obtain it.
Here you are:
ob_start();
imagepng($yourGdImageHandle);
$output = ob_get_contents();
ob_end_clean();
That is - you need to use $output
variable for you base64_encode()
function.