tarsus
08-06-2008, 01:58 PM
With the GD library functions, it seems one can only output an image resource's binary data directly, or to a file:
imagejpeg($imgresource);
imagejpeg($imgresource, $filename);
But the data stream can't simply be stored as a variable:
$datastream = imagejpeg($imgresource);
The above does not work, because imagejpeg() doesn't return a stream, it outputs it.
Why do I want to store the stream itself? Because rather than output the data directly or write a new image file, I want to store it in a database! I've used the GD functions to manipulate an image, and now I want to store the binary data of the resulting image in a database. That is, the same kind of data I would get by running fread() on an existing image.
Isn't there any way to do this?
imagejpeg($imgresource);
imagejpeg($imgresource, $filename);
But the data stream can't simply be stored as a variable:
$datastream = imagejpeg($imgresource);
The above does not work, because imagejpeg() doesn't return a stream, it outputs it.
Why do I want to store the stream itself? Because rather than output the data directly or write a new image file, I want to store it in a database! I've used the GD functions to manipulate an image, and now I want to store the binary data of the resulting image in a database. That is, the same kind of data I would get by running fread() on an existing image.
Isn't there any way to do this?