How do I give a border to an image created using PHP?
Add a border using HTMLWithin the img tag, add the border: #000000 6px outset; to the style attribute. Where you can enter your own color code, border width, and border style in the code.
The border-image property allows you to specify an image to be used as the border around an element. The border-image property is a shorthand property for: border-image-source. border-image-slice.
function drawBorder(&$img, &$color, $thickness = 1)
{
$x1 = 0;
$y1 = 0;
$x2 = ImageSX($img) - 1;
$y2 = ImageSY($img) - 1;
for($i = 0; $i < $thickness; $i++)
{
ImageRectangle($img, $x1++, $y1++, $x2--, $y2--, $color);
}
}
Then the usage would just to do.
$color = imagecolorallocate($img, 255, 0, 0);
drawBorder($img,$color, 255);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With