当我重新采样jpg以便在图像周围绘制边框时,图像的质量大大降低,并且获得了极低质量的jpeg.

这是我的代码:
function addBorderpng($add,$bdr=0,$color='#000000'){
$arr = explode('.', $add);
$extension = strtolower(end($arr));
$border=$bdr;
$im=imagecreatefromjpeg($add);
$width=imagesx($im);
$height=imagesy($im);
$img_adj_width=$width+(2*$border);
$img_adj_height=$height+(2*$border);
$newimage=imagecreatetruecolor($img_adj_width,$img_adj_height);
imageantialias($newimage, true);
$color_gb_temp =HexToRGB($color);
$border_color = imagecolorallocate($newimage, $color_gb_temp['r'], $color_gb_temp['g'], $color_gb_temp['b']);
imagefilledrectangle($newimage,0,0,$img_adj_width,$img_adj_height,$border_color);
imagealphablending($newimage, true);
imageantialias($newimage, true);
imagecopyresized($newimage,$im,$border,$border,0,0,$width,$height,$width,$height);
imagejpeg($newimage,$add,9);
}
| 归档时间: |
|
| 查看次数: |
1233 次 |
| 最近记录: |