I have an image that I have created by combining images based on database data, and was wondering hw to convert that to base 64. I tried this but the characters returned can not be decoded into an image:
$encode ="data:image/png";
imagepng($image);
echo (base64_encode($encode));
I saw this among others but that requires a path that I don’t have. Thanks for any help.
The following will allow you to get the image data without having to create a temporary file (I’ve had nightmares with temporary files before when too many users were online…)
This will output something similar to:
Which is suitable for use inside an
<img src="..." />.Edit For PHP < 5.3 without anonymous functions: