help with imagecopyresampled()
| From: | Nicki Handy | Date: | Mon, 04 Feb 2002 16:08:09 +0000 |
| Subject: | help with imagecopyresampled() | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-83416@lists.php.net to get a copy of this message | ||
I have a question about the gd function imagecopyresampled- i get an error that i'm not sending
it a valid image resourse. I believe it is the variable $new_im that is not valid- when printed, it
is a resource id not an image path. but i'm not sure. this is all the code from a function.....
if anyone cares to look
$filename=$thisimage;
$imageInfo = getimagesize($filename);
$width = $imageInfo[0];
$height = $imageInfo[1];
$destpath="./imgs";
echo "width--->$width"; ///works
echo "height--->$height"; ///works
if($width >= $height)
{
$factor = $sz/$width;
$new_width = $sz;
$new_height = $height * $factor;
}
else
{
$factor = $sz/$height;
$new_height = $sz;
$new_width = $width * $factor;
}
///this here may not be necessary- i can't imagine why it is.....
$src_img = imagecreatefromjpeg("$thisimage");
///same here
$new_im = imagecreatetruecolor($new_width,$new_height);
////THIS IS THE PROBLEM....
imagecopyresampled($new_im, $src_img, 0, 0, 0, 0, $new_width,$new_height, $width, $height);
imagejpeg($new_im, "$destpath/new_file.jpg",75);
return $new_im;
Nicki Handy
----------
http://www.idsociety.com
nhandy@idsociety.com