有没有什么简单的方法可以在图像周围添加图像边框?
原因是我想在图像周围创建阴影效果。
图像被加载为缩略图,并且是 110x75 像素......我正在考虑创建一个阴影边框,但不知道如何将它添加到图像周围,有人知道方法吗?
PHP 最好...
function addBorderpng($add){
$border=5;
$im=imagecreatefrompng($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);
$border_color = imagecolorallocate($newimage, 255, 255, 255);
imagefilledrectangle($newimage,0,0,$img_adj_width, $img_adj_height,$border_color);
imagecopyresized($newimage,$im,$border,$border,0,0,
$width,$height,$width,$height);
imagepng($newimage,$add,9);
chmod("$add",0666);
}
Run Code Online (Sandbox Code Playgroud)