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
Share on other sites

Okay, I tried [code]<?
imagerectangle(image.png, 0, 0, 149, 171, #000000);
?>[/code], but it said this: [quote]
Parse error: parse error, unexpected ';' in /home/content/e/z/e/ezevolk/html/tests/image_functions/index.php on line 3
[/quote] What did I do wrong?
Link to comment
Share on other sites

Now it says this [quote]
Warning: imagerectangle(): supplied argument is not a valid Image resource in /home/content/e/z/e/ezevolk/html/tests/image_functions/index.php on line 2
[/quote](Also, thank you for helping me with this!)
Link to comment
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.