mercredi 5 août 2015

Lost data while converting image png to base64 string


I have an image.png which is generated dynamically (barcode) and which is returned to html as

<img src="data:image/png;base64,B64STR" />

but it sometimes get defects (white dots).

To convert image to base64 string I use this code:

    ob_start();
    imagepng($img);
    $contents = ob_get_contents();
    ob_end_clean();

    return base64_encode($contents);

Can be the output buffer be the cause of lost data? Can I convert the image to base64 some other way?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire