php - Lost data while converting image png to base64 string -
i have image.png generated dynamically (barcode) , returned html
<img src="data:image/png;base64,b64str" />
but defects (white dots).
to convert image base64 string use code:
ob_start(); imagepng($img); $contents = ob_get_contents(); ob_end_clean(); return base64_encode($contents);
can output buffer cause of lost data? can convert image base64 other way?
imagepng return bool. use file_get_contents without ob :
return base64_encode(file_get_contents($img));
Comments
Post a Comment