I have generated an image resource using imagecopyresampled.
Is there a simple way to obtain the byte stream of that resource?
An indirect method would be to store the image to a file like so:
Code: Select all
// assuming this is a jpeg
ImageJPEG($resource, $filename);
// read the byte stream using fread
$stream = fread(fopen($filename, "r"), filesize($filename));is there a better way?
My ultimate goal is to save the byte stream as a blob in the database.
thanks in advance