I have a GD image resource created from imagecreatefromstring
. After some image operations, I want to convert it back to binary data. How would I do this? Can't see any functions in the manual...
Use imagejpeg, imagepng, or similar. Use output buffering if you want to dump the result to a string, rather than a file:
ob_start();
imagejpeg($im);
$image_string = ob_get_contents();
ob_end_flush();
function image_data($gdimage)
{
ob_start();
imagejpeg($gdimage);
return(ob_get_clean());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With