I have an application that currently loads images into MySQL blobs by passing fopen($fileServerTempName, 'br') into PDO parameter bidings. This works great. I received a new requirement however to edit the photos in memory, while using the imagecreatefrompng function to initially create the image object. Now I am not sure how to get a data stream from the resulting image object to load the modified image back into MySQL. How do I get a data stream from something like this:
$sourceImage = imagecreatefrompng($fileServerTempName);
// do some modifications to $sourceImage
that is in the same format that the fopen would produce? I have tried converting the variable to binary, encoding and decoding, but have had no luck. Any help would be appreciated. If at all possible I would like to avoid creating a temporary copy of the actual modified image on disk.
Thanks.