<?
//利用GD库制作小图的函数,需要GD库支持
function createsmallpic($oldpicpath,$savepath,$wh,$ww) {
$imgQuality=100;//图片质量
$max_height=$wh;//生成图片的高度
$max_width=$ww;//生成图片的宽度
$data=GetImageSize($oldpicpath);
@$small = imagecreatetruecolor($width,$height);
@$oldim = imagecreatefromstring(file_get_contents($oldpicpath));
imagecopyresampled($small,$oldim,0,0,0,0,$width,$height,imagesx($oldim),imagesy($oldim));
switch($data[2]){
case 'gif':ImagePNG($small,$savepath,100); break;
case 'jpeg':imagejpeg($small,$savepath,100); break;
case 'png':ImagePNG($small,$savepath,100); break;
default:imagejpeg($small,$savepath,100); break;
}
}
/////////////////////////////
$uploaddir = 'UPLOADS/';//文件存放路径
$temploadfile = $_FILES['File']['tmp_name'];
if($temploadfile !=""){
$temptype = end(explode(".",$_FILES['File']['name']));}
$A=$uploaddir.date("YmdHis").".".$temptype;//构造文件名
$B=$uploaddir.date("YmdHis")."s.".$temptype;//小圖
if(move_uploaded_file($temploadfile, $A))
{
createsmallpic($uploaddir.$A,$uploaddir.$B,"200","100");
}
?>
=====================
隨手寫的,沒調試過,樓主試試?
//利用GD库制作小图的函数,需要GD库支持
function createsmallpic($oldpicpath,$savepath,$wh,$ww) {
$imgQuality=100;//图片质量
$max_height=$wh;//生成图片的高度
$max_width=$ww;//生成图片的宽度
$data=GetImageSize($oldpicpath);
@$small = imagecreatetruecolor($width,$height);
@$oldim = imagecreatefromstring(file_get_contents($oldpicpath));
imagecopyresampled($small,$oldim,0,0,0,0,$width,$height,imagesx($oldim),imagesy($oldim));
switch($data[2]){
case 'gif':ImagePNG($small,$savepath,100); break;
case 'jpeg':imagejpeg($small,$savepath,100); break;
case 'png':ImagePNG($small,$savepath,100); break;
default:imagejpeg($small,$savepath,100); break;
}
}
/////////////////////////////
$uploaddir = 'UPLOADS/';//文件存放路径
$temploadfile = $_FILES['File']['tmp_name'];
if($temploadfile !=""){
$temptype = end(explode(".",$_FILES['File']['name']));}
$A=$uploaddir.date("YmdHis").".".$temptype;//构造文件名
$B=$uploaddir.date("YmdHis")."s.".$temptype;//小圖
if(move_uploaded_file($temploadfile, $A))
{
createsmallpic($uploaddir.$A,$uploaddir.$B,"200","100");
}
?>
=====================
隨手寫的,沒調試過,樓主試試?
這裡改一下:
$height=$wh;//生成图片的高度
$width=$ww;//生成图片的宽度
//利用GD库制作小图的函数,需要GD库支持
function createsmallpic($oldpicpath,$savepath,$wh,$ww) {
$imgQuality=100;//图片质量
$height=$wh;//生成图片的高度
$width=$ww;//生成图片的宽度
$data=GetImageSize($oldpicpath);
@$small = imagecreatetruecolor($width,$height);
@$oldim = imagecreatefromstring(file_get_contents($oldpicpath));
imagecopyresampled($small,$oldim,0,0,0,0,$width,$height,imagesx($oldim),imagesy($oldim));
switch($data[2]){
case 'gif':ImagePNG($small,$savepath,100); break;
case 'jpeg':imagejpeg($small,$savepath,100); break;
case 'png':ImagePNG($small,$savepath,100); break;
default:imagejpeg($small,$savepath,100); break;
}
}
/////////////////////////////
$uploaddir = 'UPLOADS/';//文件存放路径
$temploadfile = $_FILES['File']['tmp_name'];
if($temploadfile !=""){
$temptype = end(explode(".",$_FILES['File']['name']));}
$A=date("YmdHis").".".$temptype;//构造文件名
$B=date("YmdHis")."s.".$temptype;//小圖
if(move_uploaded_file($temploadfile, $uploaddir.$A))
{
createsmallpic($uploaddir.$A,$uploaddir.$B,"200","100");
}
?>