imagecopyresized just copies
| From: | Andy Pieters | Date: | Sun, 20 Nov 2005 16:14:08 +0000 |
| Subject: | imagecopyresized just copies | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-226155@lists.php.net to get a copy of this message | ||
Hi all
I wanted to make a simple script to make a resized image from an uploaded one.
I used the example found on the php.net website
list($width,$height,$type)=getimagesize($newfile);
$newwidth=350;
$newheight=50;
$thumb=imagecreatetruecolor($newwidth,$newheight);
$thumbname=str_replace(".$filedetails[extension]",
"_thumb.$filedetails[extension]",$newfile);
$main=null;
switch($type)
{case 1: $main=imagecreatefromgif($newfile); #gif
break;
case 2: $main=imagecreatefromjpeg($newfile); #jpeg
break;
case 3: $main=imagecreatefrompng($newfile); #png
break;
}
if(!(is_null($main)))
{imagecopyresized($thumb,$main,0,0,0,0,$newwidth,$newheight,$width,
$height);
switch($type)
{case 1: imagegif($main,$thumbname);
break;
case 2: imagejpeg($main,$thumbname);
break;
case 3: imagepng($main,$thumbname);
chmod($thumbname,0600); #read&write for apache only
}
imagedestroy($main);
imagedestroy($thumb);
When I examine the two files, the are binary different but size and width are
equal.
Anybody know why?
With kind regards
Andy
--
Currently not listening to amaroK
Geek code: www.vlaamse-kern.com/geek
Registered Linux User No 379093
If life was for sale, what would be its price?
www.vlaamse-kern.com/sas/ for free php utilities
--
Attachment: [application/pgp-signature]
Attachment: [application/pgp-signature]