Convert GD Image to Binary Data

I have a GD image resource created using imagecreatefromstring . After some image operations, I want to convert it back to binary data. How can I do it? Unable to see any features in the manual ...

+4
source share
2 answers

Use imagejpeg , imagepng , or similar. Use output buffering if you want to output the result to a string rather than a file:

 ob_start(); imagejpeg($im); $image_string = ob_get_contents(); ob_end_flush(); 
+6
source
 function image_data($gdimage) { ob_start(); imagejpeg($gdimage); return(ob_get_clean()); } 
0
source

Source: https://habr.com/ru/post/1300428/


All Articles