2

Is there any way to export the PNG data that's been created using the GD library's imagecreatefrompng directly to a variable, rather than echoing it or saving it to a file?

Jake Roussel
  • 631
  • 1
  • 6
  • 17
  • My guess is that you can use `ob_start` and family to catch the output when echoing the file – WizKid Jun 02 '14 at 04:14

1 Answers1

3

You can use ob_start and family to catch the output when you echoing the file. So it would look something like this:

ob_start();
imagepng($img);
$image_content = ob_get_clean();
WizKid
  • 4,888
  • 2
  • 23
  • 23