Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143
This is the forum to discuss the Wrox book Beginning PHP 6, Apache, MySQL 6 Web Development by Timothy Boronczyk, Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz; ISBN: 9780470391143
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 15th, 2009, 10:01 PM
Registered User
 
Join Date: Apr 2009
Posts: 8
Thanks: 0
Thanked 1 Time in 1 Post
Default Ch 7 imagettftext function failing to find fonts

I am new to all of this and I have been struggling to get the imagettftext() function to work as it is written in the chapter 7 code.

The putenv('GDFONTPATH=' . 'C:/Windows/Fonts') does not seem to facilitate the use of fonts in the Windows font folder...

This bit of code below is taken from the book:

PHP Code:
//change this path to match your fonts directory and the desired font
putenv('GDFONTPATH=' 'C:/Windows/Fonts');
$font 'arial';

(
SNIP)

// add the caption if requested
if (isset($_GET['capt'])) {
    
imagettftext($image12020200$font$_GET['capt']);

The only way I have gotten it to work is to set $font = 'arial.ttf' and place the arial.ttf file into my ...apache2.2/htdoc folder.

I would love to know why the putenv call is not working; any help would be appreciated.

Thanks
-K
Reply With Quote
  #2 (permalink)  
Old April 29th, 2009, 09:04 AM
Authorized User
 
Join Date: Sep 2008
Location: Oslo, , Norway.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to peirix
Default

Yeah, I'm getting the same error.

Tried copying the font into my htdocs folder, but that didn't work either.

Anyone knows why this is? Tried switching the /'s with \'s, but didn't help.
Reply With Quote
  #3 (permalink)  
Old January 27th, 2010, 08:37 AM
Registered User
 
Join Date: Jan 2010
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 7 Image Caption & Watermark?

Me too i cant even get the above workaround to work...

I can't get the Caption & Watermark to work on page 202 onwards?!

I have downloaded the original code...changed the paths to my htdocs. But this still doesn't work....everything else but this.

Help.
Reply With Quote
  #4 (permalink)  
Old February 13th, 2010, 01:48 AM
Authorized User
Points: 105, Level: 2
Points: 105, Level: 2 Points: 105, Level: 2 Points: 105, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2010
Location: Wolfeboro, New Hampshire / Boston
Posts: 25
Thanks: 1
Thanked 4 Times in 4 Posts
Default Solution or workaround

I replaced the two relevant lines of codes at the top of both check_image.php and image_effect.php with the following:

Code:
putenv("GDFONTPATH=" . "C:/Windows/Fonts/");
$font = getenv('GDFONTPATH') . 'arial.ttf';
This solved the problem, at least on Windows Vista.

HTH,
Boz
Reply With Quote
  #5 (permalink)  
Old February 13th, 2010, 02:22 AM
Authorized User
Points: 105, Level: 2
Points: 105, Level: 2 Points: 105, Level: 2 Points: 105, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2010
Location: Wolfeboro, New Hampshire / Boston
Posts: 25
Thanks: 1
Thanked 4 Times in 4 Posts
Default

And BTW, don't put any debugging statements in the image_effect.php file, like echo $font, or anything else that causes output. Because this file is called as the src attribute of an image element, it can only generate an image, not text output. When I tried to use echo to see what my variables and arrays were holding, the check_image program tried to put that where it expected an image. The result was no image, and annoyingly, no output or even an error message in the php-error log.

I think using an image generating program as the src attribute is pretty cool. But if anyone knows a way to get error and debugging info out of it, I'd love to here it. There must be a way to use stderr or stdout to do this on Linux, but on Windows? Any ideas?

Regards,
Boz
Reply With Quote
  #6 (permalink)  
Old March 3rd, 2010, 12:02 PM
Authorized User
 
Join Date: Dec 2009
Posts: 14
Thanks: 3
Thanked 0 Times in 0 Posts
Unhappy

Quote:
Originally Posted by BozHogan View Post
I replaced the two relevant lines of codes at the top of both check_image.php and image_effect.php with the following:

Code:
putenv("GDFONTPATH=" . "C:/Windows/Fonts/");
$font = getenv('GDFONTPATH') . 'arial.ttf';
This solved the problem, at least on Windows Vista.

HTH,
Boz
After this replaced lines i have the same problem... The code does'nt work!
Can you Help me?
Reply With Quote
Reply


Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
CH. 7 imagettftext function error ttpdotcom BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 2 January 29th, 2010 01:12 PM
VBScript find missing number function?? mat41 Classic ASP Professional 6 February 12th, 2007 07:07 PM
Function to find if a letter is in a word jfrizelle Access VBA 2 January 29th, 2007 05:44 PM
Function to Find a Record me2357 Access VBA 5 March 10th, 2005 03:22 PM
Ch 17: where to find free pop access / forwarding dmswdev JSP Basics 1 June 27th, 2003 06:14 AM



All times are GMT -4. The time now is 12:03 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.