Ok,I now realized that imagecopyresize does not actually resize original image for good,but just resizes the display.
I can live with that.
Can someone help me to get this piece of code save the created thumbernail instead of outputing the resized result on the fly to the browser ?
I want the created thumbernail saved in the same directory as the original uploaded image.Even better overwrites it and just keep the reduced version.
[code=php]
$imagepath = $uploaddir.$ima geName;
list($width,$he ight)=getimages ize($imagepath) ;
if($height > 480){
$image = imagecreatefrom jpeg($imagepath );
$newheight=480;
$newwidth=($wid th/$height)*480;
$thumb = imagecreatetrue color($newwidth ,$newheight);
imagecopyresamp led($thumb,$ima ge,0,0,0,0,$new width,$newheigh t,$width,$heigh t);
imagejpeg($thum b,$image,100);
imagedestroy($i mage);
imagedestroy($t humb);
}
else if($width > 620){
$image = imagecreatefrom jpeg($imagepath );
$newwidth=620;
$newheight=($he ight/$width)*620;
$thumb =imagecreatetru ecolor($newwidt h,$newheight);
imagecopyresamp led($thumb,$ima ge,0,0,0,0,$new width,$newheigh t,$width,$heigh t);
header("Content-Type: image/jpeg");
imagejpeg($thum b,$image,100);
imagedestroy($i mage);
imagedestroy($t humb);
}
echo "<img src\"$imagepath \" height=\"$newhe ight\" width=\"$newwid th\" />";
[/code]
< Please use [code] tags when posting code! -Atli >
I can live with that.
Can someone help me to get this piece of code save the created thumbernail instead of outputing the resized result on the fly to the browser ?
I want the created thumbernail saved in the same directory as the original uploaded image.Even better overwrites it and just keep the reduced version.
[code=php]
$imagepath = $uploaddir.$ima geName;
list($width,$he ight)=getimages ize($imagepath) ;
if($height > 480){
$image = imagecreatefrom jpeg($imagepath );
$newheight=480;
$newwidth=($wid th/$height)*480;
$thumb = imagecreatetrue color($newwidth ,$newheight);
imagecopyresamp led($thumb,$ima ge,0,0,0,0,$new width,$newheigh t,$width,$heigh t);
imagejpeg($thum b,$image,100);
imagedestroy($i mage);
imagedestroy($t humb);
}
else if($width > 620){
$image = imagecreatefrom jpeg($imagepath );
$newwidth=620;
$newheight=($he ight/$width)*620;
$thumb =imagecreatetru ecolor($newwidt h,$newheight);
imagecopyresamp led($thumb,$ima ge,0,0,0,0,$new width,$newheigh t,$width,$heigh t);
header("Content-Type: image/jpeg");
imagejpeg($thum b,$image,100);
imagedestroy($i mage);
imagedestroy($t humb);
}
echo "<img src\"$imagepath \" height=\"$newhe ight\" width=\"$newwid th\" />";
[/code]
< Please use [code] tags when posting code! -Atli >
Comment