Re: how do I make thumnails

From: Date: Thu, 21 Dec 2000 18:35:02 +0000
Subject: Re: how do I make thumnails
Groups: php.general 
Request: Send a blank email to php-general+get-31457@lists.php.net to get a copy of this message
<? $prod_r = fetch_db_value("product_image", $query) ) $fname = "/tmp/php/" . mtime(); $fp = fopen($fname, "w"); fwrite($fp, $prod_r["image_data"], strlen($prod_r["image_data"])); fclose($fp); $src_img = imagecreatefromjpeg($fname); $new_h = 100; $new_w = $new_h * ( imagesx($src_img) / imagesy($src_img) ); $dst_img = imagecreate($new_w,$new_h); imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img)); Header("Content-Type: {$prod_r["image_type"]}"); imagejpeg($dst_img, '', 95); unlink($fname); exit(); ?> ok now this will work, but there are better ways in php-4.0.4 but I havent had time to re-write it yet. php's newest version will allow you todo all this in memory without the need of writeing the data to the HD. ImageCreateFromString() is the new function to look at, I can't seem to find it in http://php.net/manual http://snaps.php.net/manual/en/html/ I heard reference of it in the newest change_log Chris Lee Mediawaveonline.com

« previous php.general (#31457) next »