If you read your Imagedata from a Database Blob and use the functions from above to resize the image to a thumbnail improving a lot of traffic, you will have to make temporary copies of the files in order that the functions can access them
Here a example:
// switch through imagetypes
$extension = "jpg";
if(mysql_result($query, 0, 'type') == "image/pjpeg")
{ $extension = "jpg"; } // overwrite
else if(mysql_result($query, 0, 'type') == "image/gif")
{ $extension = "gif"; } // overwrite
// get a temporary filename
// use microtime() to get a unique filename
// if you request more than one file f.e. by creating large numbers of thumbnails, the server could be not fast enough to save all these different files and you get duplicated copies and resizepics() will resize and output often the same content
$filename = microtime()."_temp.".$extension;
// open
$tempfile = fopen($filename, "w+");
// write
fwrite($tempfile, mysql_result($query, 0, 'image'));
// close
fclose($tempfile);
// resize and output the content
echo resizepics($filename, '100', '70');
// delete temporary file
unlink($filename);
NOTE: this script has to be put into a file which sends correct header informations to the browser, otherwise you won't get more to see than a big red cross :-)