Well, my question is very simple, i just wanna convert the output of imagepng/imagejpg to base64, how i can do this ? the correctly way is with capturing output buffer ? thanks.
imagepng
imagejpeg/imagepng doesn't return any data, they write the image data directly to the output stream (or to a file).
imagejpeg
If you'd like to capture this data encoded as base64 the easiest method is to use PHPs Output Control Functions, and then use base64_encode on the $image_data.
base64_encode
$image_data
ob_start (); imagejpeg ($img); $image_data = ob_get_contents (); ob_end_clean (); $image_data_base64 = base64_encode ($image_data);
1.4m articles
1.4m replys
5 comments
57.0k users