(PHP 4.23, GD 1.6.2 or higher) Hiya, I have code to place the picture in a database, and I normally shrink it when the user requests a picture. What I would like it to change to is that it should shrink or expand the picture to be 300 pixels wide and then place it into the database. I thought the function below would work to do to return a text resized version.
It does sort of works, but makes a picture where only part of it is the picture (top part), the rest is blank. Any help would be gr8! THanks, Steve function shrink_picture($tmp_name,$size,$name) { $result = ereg(".gif$",strtolower($name)); if($result) { $img = imagecreatefromgif($tmp_name); } else { $img = imagecreatefromjpeg($tmp_name); } $width = imagesx($img); $height = imagesy($img); $new_height = abs(300.0 * ($height/$width)); $new_img = imagecreate(300, $new_height ); imagecopyresized($new_img,$img,0,0,0,0,300,$new_height,imagesx($img),imagesy ($img)); imagejpeg($new_img,$tmp_name."a",70); imagedestroy($new_img); imagedestroy($img); $data = addslashes(fread(fopen($tmp_name."a","r"),$size)); return $data; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php