1.用imagecreatetruecolor和imagecopyresampled函数分别取代imagecreate和imagecopyresized
2.给imagejpeg的第三个参数带上100(例:imagejpeg($ni,$tofile,100))
imagecreatetruecolor -- 新建一个真彩色图像
说明
resource imagecreatetruecolor ( int x_size, int y_size )
imagecreatetruecolor() 返回一个图像标识符,代表了一幅大小为 x_size 和 y_size 的黑色图像
*/
header ("content-type: image/png");
$im = @imagecreatetruecolor (50, 100)
or die ("cannot initialize new gd image stream");
$text_color = imagecolorallocate ($im, 233, 14, 91);
imagestring ($im, 1, 5, 5, "a simple text string", $text_color);
imagepng ($im);
imagedestroy ($im);/*
如果使用普通的imagecreate()函数将造成图片质量失真的情况,从网上搜了一下解决办法,方法是用imagecreateruecolor()函数替换imagecreate()函数。
*/
function createpreview($img,$name,$path,$maxwidth,$maxheight,$quality){//图片,保存名称,保存路径,最大宽,最大高,质量
$widthratio=0;
$heightratio=0;
$width=imagesx($img);
$height=imagesy($img);
//开始计算缩小比例
if($width>$maxwidth||$height>$maxheight){
if($width>$maxwidth){
$widthratio=$maxwidth/$width;
}
if($height>$maxheight){
$heightratio=$maxheight/$height;
}
if($widthratio>0&&$heightratio>0){
if($widthratio<$heightratio){
$ratio=$widthratio;
}else{
$ratio=$heightratio;
}
}elseif($widthratio>0){
$ratio=$widthratio;
}elseif($heightratio>0){
$ratio=$heightratio;
}
//根据得出的比例,重新计算缩略图的宽和高
$newwidth=$ratio*$width;
$newheight=$ratio*$height;
$newimg=imagecreatetruecolor($newwidth,$newheight); // 创建目标图
imagecopyresized($newimg,$img,0,0,0,0,$newwidth,$newheight,$width,$height);
imagejpeg($newimg,$path."s_".$name,$quality);
imagedestroy($newimg);
}else{
imagejpeg($img,$path."s_".$name,$quality);
}
}
/*
imagecopyresamples() ,其像素插值算法得到的图像边缘比较平滑.质量较好(但该函数的速度比 imagecopyresized() 慢).
荒野乱斗国际版 (BrawlStars)最新版本v56.274
下载一波超人内置修改器菜单版 安卓版v1.0.2
下载敢达决战官方正版 安卓版v6.7.9
下载敢达决战 安卓版v6.7.9
下载继承了一座戏园子无限声望铜钱版 内置菜单最新版v1.7
继承了一座戏园子折相思版是游戏的破解版本,在该版本中为玩家提
山河半世橙光清软金手指版 无限鲜花v3.24
山河半世是一款超级好玩的橙光恋爱游戏,在游戏中玩家们需要扮演
蓬莱手游折相思版 安卓版v1.0.0
蓬莱免广告版是游戏的修改版本,在该版本中为玩家去除了广告,玩
当红影后橙光游戏破解版2025 最新版v1.0
当红影后橙光破解版是一款超级好玩的娱乐圈题材的橙光游戏,在这
忽然成了万人迷清软完结版 无限鲜花版v12.15
忽然成了万人迷破解版是一款非常好玩的男性向橙光游戏,在有一天