Home Tutorial Php Phpgd PHP GD Add Border to image


Share on Google+Share on Google+
PHP GD Add Border to image
Posted on: October 30, 2009 at 12:00 AM
In this PHP tutorial we know about how to add border to the images in the PHP GD Library.


$im = imagecreate(200, 60);

$bg = imagecolorallocate($im, 225, 225, 225);

$textcolor = imagecolorallocate($im, 0, 0, 255);

imagestring($im, 5, 30, 20, "Roseindia", $textcolor);

$bordercolors = imagecolorallocate($im, 255, 255, 20); //Define border color Yellow

$x = 0;

$y = 0;

$w = imagesx($im) - 1;

$h = imagesy($im) - 1;

imageline($im, $x,$y,$x,$y+$h,$bordercolors);

imageline($im, $x,$y,$x+$w,$y,$bordercolors);

imageline($im, $x+$w,$y,$x+$w,$y+$h,$bordercolors);

imageline($im, $x,$y+$h,$x+$w,$y+$h,$bordercolors);

header("Content-type: image/png");



After running the program you will get the following output


Related Tags for PHP GD Add Border to image:

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 30, 2009

Recommend the tutorial

Advertisements Advertisements