Home Tutorial Php Phpgd PHP GD Add Border to image

 
 

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.

<?php

$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");

imagepng($im);

?>

After running the program you will get the following output

Related Tags for PHP GD Add Border to image:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.