Jump to content

Image Border Create


EZE

Recommended Posts

just use CSS, unless you want the border to be apart of the image.

then

[code]// Create border around image
imageline($image, 0, 0, 0, $imgHeight, $colorGrey);
imageline($image, 0, 0, $imgWidth, 0, $colorGrey);
imageline($image, $imgWidth-1, 0, $imgWidth-1, $imgHeight-1, $colorGrey);
imageline($image, 0, $imgHeight-1, $imgWidth-1, $imgHeight-1, $colorGrey);[/code]
Link to comment
https://forums.phpfreaks.com/topic/35281-image-border-create/#findComment-166762
Share on other sites

You don't give the image functions the filename, you give them a file handle. E.g:
[code]
$im = imagecreatefrompng( 'image.png' );
$black = imagecolorallocate($im,0,0,0);
imagerectangle($im, 0, 0, 149, 171, $black);

//WARNING, THIS WILL OVERWRITE THE ORIGINAL!!
imagepng($im,'image.png');
[/code]

The above code should create the border and overwrite the old file with the new image.
Link to comment
https://forums.phpfreaks.com/topic/35281-image-border-create/#findComment-166785
Share on other sites

Cool! That worked! Now, if my image is 149 by 171, should i set the finishing x and y positions to be that? Because I did, and the image's border cut off in the bottom and right sides of the image, they didn't show up at all. Do I have to subtract 1 from each finishing coordinate?
Link to comment
https://forums.phpfreaks.com/topic/35281-image-border-create/#findComment-166824
Share on other sites

Okay, thank you. What if I wanted to expand the image by 1px on all sides, leaving blank pixels, not stretching out the image, then applying the border. For example, i have a 50 by 50 image, and i draw a 1 px border all the way around it, and the border expands the image size, but the image stays the same. Pretty much like adding a css border.
Link to comment
https://forums.phpfreaks.com/topic/35281-image-border-create/#findComment-166856
Share on other sites

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.