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?
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();