Jump to content

Add border to image with transparency.


53329

Recommended Posts

Title says it all but here is the code I have for reference anyway.  Is there a way to add a border around the edge of this image without copying it?  Keep in mind that the image has transparency.

 

<?php
$im = imagecreatefromgif("test.gif");
header("Content-type: image/gif");
imagegif($im);
imagedestroy($im);
?>

 

Thanks in advance for any help.

Link to comment
https://forums.phpfreaks.com/topic/91633-add-border-to-image-with-transparency/
Share on other sites

Fixed it.  Here is for anyone else as I couldn't find this online.

<?php
$im = imagecreatefromgif("test.gif");
$width=imagesx($im);
$height=imagesx($im);
$border_color = imagecolorallocatealpha($im, 0, 0, 0, 0);
imageline($im, 0, 0, ($width-1), 0, $border_color);
imageline($im, 0, ($height-1), ($width-1), ($height-1), $border_color);
imageline($im, 0, 0, 0, ($height-1), $border_color);
imageline($im, ($width-1), 0, ($width-1), ($height-1), $border_color);
header("Content-type: image/gif");
imagegif($im);
imagedestroy($im);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.