Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Add border to images with GD
Old 01-11-2005, 06:18 PM Add border to images with GD
Unknown.

Posts: 1,693
Trades: 0
Is is possible to add a border to an image using GD..

What I simple want to do is add a 1px border around images.. searched google but couldnt find nothing

Thanks
James
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-12-2005, 05:29 AM
Wenslock's Avatar
Webmaster Talker

Posts: 746
Location: Lincoln, UK
Trades: 0
why not just use a css script?
__________________
------------------------------------------------------------

Please login or register to view this content. Registration is FREE
- Black Prism professional web design services
------------------------------------------------------------
Wenslock is offline
Reply With Quote
View Public Profile
 
Old 01-12-2005, 10:55 AM
Unknown.

Posts: 1,693
Trades: 0
Because what im doing is creating dynamic images which people need to link to.. so cant use css
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Old 01-13-2005, 02:30 AM hi
Mooofasa's Avatar
Defies a Status

Posts: 1,611
Name: Michael (mik) Land
Location: England
Trades: 0
Can you show us the code or an example?

--twitch
__________________

Please login or register to view this content. Registration is FREE
- Tumblog with thoughts, quotes, links, videos, images and my creations.

Please login or register to view this content. Registration is FREE
- The best free web browser.

Please login or register to view this content. Registration is FREE
- Firefox is now Firefail.
Mooofasa is offline
Reply With Quote
View Public Profile Visit Mooofasa's homepage!
 
Old 01-13-2005, 07:05 AM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Trades: 0
Quote:
Originally Posted by Twitch
Can you show us the code or an example?
I think what James is asking for is the code to do so. I am equally interested in any good GD information resources anyone may have.
__________________
—Kyrnt
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Old 01-17-2005, 03:11 PM
Unknown.

Posts: 1,693
Trades: 0
Yea I was wanting the code for how to do it..

Ive looked everywhere and since no-one has posted I quess its not possible..

But ive thought of a work around..

Get the size of the image.. Then create an image 2px wider and 2px taller and then merge the two images together so there is a 1px border around the image..

Got the basics just need to perfect it now
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Old 01-17-2005, 03:17 PM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
I am not familiar with GD to a great extent but it seems to me that this would be a logical solution...

Create the image with GD and cache it so that you don't have to create it every single page load. Then when calling the image simply add the border attribute to the img tag.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 01-17-2005, 03:34 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
This works:
PHP Code:
<?php

$img 
ImageCreateFromJPEG('img.jpg');

// Draw border
$color_black ImageColorAllocate($img000);
drawBorder($img$color_black3);


// Output
header('Content-type: image/jpeg');
ImageJPEG($img);



// Draw a border
function drawBorder(&$img, &$color$thickness 1)
{
    
$x1 0;
    
$y1 0;
    
$x2 ImageSX($img) - 1;
    
$y2 ImageSY($img) - 1;

    for(
$i 0$i $thickness$i++)
    {
        
ImageRectangle($img$x1++, $y1++, $x2--, $y2--, $color_black);
    }
}

?>
You can change the type of image by using different ImageFrom* and Image* functions (be sure to change Content-type), but everything else should work.
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 01-17-2005, 04:51 PM
Unknown.

Posts: 1,693
Trades: 0
Thanks
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Add border to images with GD
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.28730 seconds with 12 queries