I've wrote a script that resizes uploaded images. The funktion imagejpeg() create a jpeg stream, either to a file or diectly to the screen. Is it possible to capture the stream into a varable? If so it could easily be stored in a database.
Unfortunately, imagejpeg() return a boolean value. I tried to put the image resizing code, including the imagejpeg() function i a separate file, hoping that the output from that file could be captured i a variable in the file witch called it. Is that possible, and could someone please show me how that code would lool like that calls the "create_thumbnail.php" file.
Here's the rezising code:
<?php
$src_file = $_GET[image];
$src_handle = fopen($src_file, "r");
$src_img = imagecreatefromjpeg($src_file);
$dest_img = imagecreatetruecolor(120, 100);
imagecopyresampled($dest_img, $src_img, 0, 0, 0, 0, 120, 100, imagesx($src_img), imagesy($src_img));
imagejpeg($dest_img, '', 75);
fclose($src_handle);
?>