我正在使用一個簡單的圖像上傳php代碼,但圖像質量下降爲100x100 50x50。我怎樣才能提高圖像質量?圖像質量下降在php文件圖像上傳
我想在上傳照片時使用高質量的照片。
if($extension=="jpg" || $extension=="jpeg")
{
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);
}
else if($extension=="png")
{
$uploadedfile = $_FILES['file']['tmp_name'];
$src= imagecreatefrompng($uploadedfile);
imagealphablending($src, false);
imagesavealpha($src, true);
imagealphablending($src, false);
imagesavealpha($src, true);
}
else
{
$src = imagecreatefromgif($uploadedfile);
}
echo $scr;
list($width,$height)=getimagesize($uploadedfile);
if($width>75)
{
$newwidth=50;
$newheight=($height/$width)*$newwidth;
$tmp=imagecreatetruecolor($newwidth,$newheight);
$newwidth1=100;
$newheight1=($height/$width)*$newwidth1;
$tmp1=imagecreatetruecolor($newwidth1,$newheight1);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height);
$ext = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
$mainfilename = $username.".".$ext;
$filename = "pics/50/". $username.".".$ext;
$filename1 = "pics/100/". $username.".".$ext;
imagejpeg($tmp,$filename,50);
imagejpeg($tmp1,$filename1,100);
任何人都可以幫助我創建4大小的縮略圖照片使用一張大照片,但質量好嗎?