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

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -