Menu
Hello
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=php]
// assuming this is a jpeg
ImageJPEG($resource, $filename);
// read the byte stream using fread
$stream = fread(fopen($filename, “r”), filesize($filename));
This method is awkward because it may be slow (generating a file) and I would need to delete the file afterwards.
is there a better way?
My ultimate goal is to save the byte stream as a blob in the database.
thanks in advance