Search code examples
phpjpeg

php : How to create a string of image binary without saving it to a file?


I have an image variable,

$im = imagecreatetruecolor(400, 300);

Is there anyway to get a string of binary of this image in jpeg format without saving it to a file? Thanks!


Solution

  • ob_start();
    imagejpeg($im);
    $imageString = ob_get_clean();