I have not tested this, but I think it will do the trick.
function addBorder($image, $width, $height) { $gd = imagecreatetruecolor($width, $height); for($i = 0; $i<$height; $i++) { // add left border imagesetpixel($image,0,$i, imagecolorallocate($gd, 0,0,0) ); // add right border imagesetpixel($image,$width-1,$i, imagecolorallocate($gd, 0,0,0) ); } for($j = 0; $j<$width; $j++) { // add bottom border imagesetpixel($image,$j,0, imagecolorallocate($gd, 0,0,0) ); // add top border imagesetpixel($image,$j,$height-1, imagecolorallocate($gd, 0,0,0) ); } return $image; } $image = //your image $width = //your iimage width $height = //your image height $image = addBorder($image, $width, $height);
Jd isaacks
source share