Issue
How to create thumbnail images with white 3px border using PHP?
Solution
Haven't actually tried this but I think something like this might work
<?php
/*
* Function to create a border around an image
*/
function drawBorder($image_name, $r = 0, $g = 0, $b = 0, $thickness = 1)
{
$image = ImageCreateFromJPEG($image_name);
$color = ImageColorAllocate($img, $r, $g, $b);
$x1 = 0;
$y1 = 0;
$x2 = ImageSX($image) - 1;
$y2 = ImageSY($image) - 1;
for($i = 0; $i < $thickness; $i++)
{
ImageRectangle($image, $x1++, $y1++, $x2--, $y2--, $color);
}
return $image;
}
?>
Then run something like
<?php
header('Content-type: image/jpeg');
ImageJPEG(drawBorder("images/foo.jpg", 128, 128, 0, 3));
?>
Answered By - inquam Answer Checked By - Gilberto Lyons (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.