Old 29-04-2007, 11:18   #1 (permalink)
RaelRode
Designers are strange :)
 
RaelRode's Avatar
 
Join Date: Jan 2007
Location: Shrewsbury, UK
Posts: 1,730
Send a message via ICQ to RaelRode Send a message via AIM to RaelRode Send a message via MSN to RaelRode Send a message via Yahoo to RaelRode Send a message via Skype™ to RaelRode
Subnav Script

OK so I found this script which basically puts text over an image so I dont need to create loads of images for my subnav. Here it is....

PHP Code:
<?
header
('Content-type: image/gif');
$im = @imagecreatefromgif('_img/nav_link.gif');
$black imagecolorallocate($im51102153);
$font 'Verdana';
$text strtoupper($_REQUEST['text']);

$box imagettfbbox 6.40$font$text);
$tw=$box[2]-$box[0];
$th=$box[5]-$box[3];
$px = (imagesx($im) -$tw)/2;
$py = (imagesy($im) -$th)/2;

imagettftext($im6.40$px12$black$font$text);
imagegif($im);
imagedestroy($im);
?>

The only problem is that it doesn't work. My images are in the right place etc but it doesn't show up. I am using it here.

Any ideas????
  Reply With Quote
Old 29-04-2007, 16:28   #2 (permalink)
freelancr
Senior Member
 
freelancr's Avatar
 
Join Date: Oct 2006
Posts: 2,203
Could be either one of the following:
- I think older versions of GD cannot save as GIF, try PNG or JPG
- I thought you had to upload the font file to the server and link to it in the script. Verdana is not included in Linux by default.
- Is your "nav_link.gif" file really in a subdirectory called _img? seems wierd to use an underscore like that
- Perhaps you have to reference locations local PATH (ie /var/www/blah/img/rar.gif)
- "imagedestroy($im);" sounds like you are making the image, then destroying it? you really should save the image, instead of making the script create it each time the page is loaded.
  Reply With Quote
Old 29-04-2007, 16:36   #3 (permalink)
gk
geek
 
gk's Avatar
 
Join Date: Oct 2006
Location: *.everywhere
Posts: 204
Send a message via ICQ to gk Send a message via AIM to gk Send a message via MSN to gk Send a message via Yahoo to gk
try commenting out "header('Content-type: image/gif');" then viewing the script maybe it's giving you an error that might help you out.
  Reply With Quote
Old 04-05-2007, 16:01   #4 (permalink)
RaelRode
Designers are strange :)
 
RaelRode's Avatar
 
Join Date: Jan 2007
Location: Shrewsbury, UK
Posts: 1,730
Send a message via ICQ to RaelRode Send a message via AIM to RaelRode Send a message via MSN to RaelRode Send a message via Yahoo to RaelRode Send a message via Skype™ to RaelRode
Well I got the script off a friend and it seemed to work for him. Yes I use an underscore (_) for all my image/include directories, wwhats wrong with that?! lol.

Thanks for the help anyway guys.
  Reply With Quote
Old 05-05-2007, 01:28   #5 (permalink)
gk
geek
 
gk's Avatar
 
Join Date: Oct 2006
Location: *.everywhere
Posts: 204
Send a message via ICQ to gk Send a message via AIM to gk Send a message via MSN to gk Send a message via Yahoo to gk
I'm sure your problem is PHP is not finding the image(s) in that location.
Code:
$im = @imagecreatefromgif('_img/nav_link.gif');

And why is there an @ in front of the function call? The @ is to hide or prevent the function call from generating an error. you should really check if the file exists using file_exists() rather then preventing the error.

change the first few lines to this:
PHP Code:
//header('Content-type: image/gif');
$im imagecreatefromgif('_img/nav_link.gif'); 

then visit this link and you shuld get an error message that will help you out.
http://www.publicwebserver.com/nav_link.php?text=Home
  Reply With Quote
Old 05-05-2007, 06:25   #6 (permalink)
RaelRode
Designers are strange :)
 
RaelRode's Avatar
 
Join Date: Jan 2007
Location: Shrewsbury, UK
Posts: 1,730
Send a message via ICQ to RaelRode Send a message via AIM to RaelRode Send a message via MSN to RaelRode Send a message via Yahoo to RaelRode Send a message via Skype™ to RaelRode
OK so now I get an error, but no idea what it means though. lol. Im crap with PHP!
  Reply With Quote
Old 05-05-2007, 06:30   #7 (permalink)
Larixk
Senior Member
 
Larixk's Avatar
 
Join Date: Sep 2006
Location: Utrecht, Netherlands
Posts: 1,031
Send a message via MSN to Larixk
well, post it here.
  Reply With Quote
Old 12-05-2007, 04:08   #8 (permalink)
RaelRode
Designers are strange :)
 
RaelRode's Avatar
 
Join Date: Jan 2007
Location: Shrewsbury, UK
Posts: 1,730
Send a message via ICQ to RaelRode Send a message via AIM to RaelRode Send a message via MSN to RaelRode Send a message via Yahoo to RaelRode Send a message via Skype™ to RaelRode
Quote:
<img>The image “http://www.publicwebserver.com/nav_link.php” cannot be displayed, because it contains errors.

It was something different but I've been away again because my PC broke so I got a new one. :p
  Reply With Quote
Old 12-05-2007, 10:32   #9 (permalink)
gk
geek
 
gk's Avatar
 
Join Date: Oct 2006
Location: *.everywhere
Posts: 204
Send a message via ICQ to gk Send a message via AIM to gk Send a message via MSN to gk Send a message via Yahoo to gk
Quote:
Originally Posted by gk
I'm sure your problem is PHP is not finding the image(s) in that location.
Code:
$im = @imagecreatefromgif('_img/nav_link.gif');

And why is there an @ in front of the function call? The @ is to hide or prevent the function call from generating an error. you should really check if the file exists using file_exists() rather then preventing the error.

change the first few lines to this:
PHP Code:
//header('Content-type: image/gif');
$im imagecreatefromgif('_img/nav_link.gif'); 

then visit this link and you shuld get an error message that will help you out.
http://www.publicwebserver.com/nav_link.php?text=Home

Do this and you should get something more informative.
__________________
Quote:
"Why reinvent the wheel"? Simply because it's not round enough and I don't like the treads.
  Reply With Quote
Old 12-05-2007, 11:14   #10 (permalink)
pgo
Senior Member
 
Join Date: Jan 2005
Posts: 12,340
Quote:
Originally Posted by freelancr
- Is your "nav_link.gif" file really in a subdirectory called _img? seems wierd to use an underscore like that
That way when you look at the root in alphabetic order, naming something with a preceding underscore will force it to appear at the top of the order. Some people do that, like...

"/_css/"
"/_images/"
"/_scripts/"
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8