Re: [PHP] Writing text into images, and setting text size [SOLVED]

2007-12-19 Thread Dave M G

Rob,

Thank you for helping me through this.


'--enable-gd-native-ttf'
'--with-ttf'


This was the key information. I thought that having the GD modules 
installed meant I had TTF support. But after I saw that, I realized that 
TTF support was a separate module within the GD library.


On my home Ubuntu environment, placing TTF support simply meant 
installing the right package from the repository (which I found in 
Synaptic by searching for PHP TTF).


I'm hoping that TTF support is reasonably common on web hosting 
services, since I'm aspiring for my code to be portable.


In any case, you've helped me get to the point that I needed to get to, 
so I am very grateful for your support.


Thanks.

--
Dave M G

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Writing text into images, and setting text size [SOLVED]

2007-12-19 Thread Andrés Robinet
Hi Dave,

Thanks for the compliment! :)

About TTF support in shared hosting... every decent hosting option should 
support it. Though it is kind of an optional feature, it is as common as GD 
itself (at least 9 out of 10 CAPTCHA scripts will rely on it). So if TTF 
support is not installed, the hosting provider should install it. How they 
should install it is up to them, and varies from system to system.
In other words, if TTF support is not installed and your hosting provider is 
not willing to install it (or wants to charge you for that), either they don't 
have a clue, or they want to take advantage of your needs... in both cases the 
service sucks. We use CentOS boxes with DirectAdmin, and installing GD with TTF 
support is part of the standard setup.
You cannot rely on ImageMagick, or the PHP ImageMagick extension being 
installed, though some hosting companies support it. But GD with TTF, Freetype, 
JPG and PNG support is pretty standard, like mbstring, cURL, or the sockets 
extension.

Best Regards,

Rob


Andrés Robinet | Lead Developer | BESTPLACE CORPORATION
5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 | 
TEL 954-607-4207 | FAX 954-337-2695
Email: [EMAIL PROTECTED]  | MSN Chat: [EMAIL PROTECTED]  |  SKYPE: bestplace |  
Web: http://www.bestplace.biz | Web: http://www.seo-diy.com

 -Original Message-
 From: Dave M G [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, December 19, 2007 7:49 AM
 To: Andrés Robinet
 Cc: 'PHP List'
 Subject: Re: [PHP] Writing text into images, and setting text size
 [SOLVED]
 
 Rob,
 
 Thank you for helping me through this.
 
  '--enable-gd-native-ttf'
  '--with-ttf'
 
 This was the key information. I thought that having the GD modules
 installed meant I had TTF support. But after I saw that, I realized
 that
 TTF support was a separate module within the GD library.
 
 On my home Ubuntu environment, placing TTF support simply meant
 installing the right package from the repository (which I found in
 Synaptic by searching for PHP TTF).
 
 I'm hoping that TTF support is reasonably common on web hosting
 services, since I'm aspiring for my code to be portable.
 
 In any case, you've helped me get to the point that I needed to get to,
 so I am very grateful for your support.
 
 Thanks.
 
 --
 Dave M G
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Writing text into images, and setting text size

2007-12-18 Thread Dave M G

Rob,

Thank you for responding.


Try the following:
... you load PrintImage.php into your browser and you'll get a nice gray rectangle with the word Works! in the center of it. 
 If you don't get that... then you have a problem that is not related 
to path or to PHP per-se...


Wow... thank you so much for providing that code to help me test my 
environment.


I ran your script - with the corrections you provided - and did not get 
the text that says Works!.


I've checked with various fonts, and checked that they worked in 
OpenOffice and other apps, so I don't think fonts are the problem.


As for GD support, phpinfo() it says:

GD Support  enabled
GD Version  2.0 or higher
FreeType Supportenabled
FreeType Linkagewith freetype
FreeType Version2.1.9
T1Lib Support   enabled
GIF Read Supportenabled
GIF Create Support  enabled
JPG Support enabled
PNG Support enabled
WBMP Supportenabled
GetText Support enabled

Am I missing a necessary module?


Hope this helps


It helps very much. Thank you.

--
Dave M G

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Writing text into images, and setting text size

2007-12-18 Thread Andrés Robinet
Hi Dave,

Take a look
http://www.bestplace.biz/unittest/ttf/PrintImage.php

... and replace PrintImage.php with info.php in the URL to get the phpinfo.
See the CONFIGURE COMMAND line for the phpinfo (at the very beginning):
'--with-gd'
'--enable-gd-native-ttf'
'--with-ttf'
'--with-jpeg-dir=/usr/local/lib'
'--with-freetype-dir=/usr/local/lib'
'--with-png-dir=/usr/local/lib'

You might need to change /usr/local/lib according to your system configuration 
(this is a CentOS 4 box with DirectAdmin as the hosting control panel) and 
recompile PHP. However, before you run into an unnecessary mess...

1 - Add this line to the very beginning of the script and remove the code that 
outputs the image (all the header stuff and the imagepng($im) sentence):

error_reporting(E_ALL);

I guess you have already don that but just in case... If there's an error you 
should see it with E_ALL

2 - If you find out that the problem is definitely PHP, you'd better off using 
the provided upgrade methods of your hosting control panel, or a standard or 
custom script provided at the hosting control panel's website. That will make 
your life easier (For DirectAdmin, there's custombuild, for others... I don't 
know)... otherwise, you'll have to edit the configure script, and run 
./configure, make and make install as usual (and troubleshoot as usual).

Hope you get it working, :)

Rob

 -Original Message-
 From: Dave M G [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, December 18, 2007 7:06 AM
 To: Andrés Robinet
 Cc: 'PHP List'
 Subject: Re: [PHP] Writing text into images, and setting text size
 
 Rob,
 
 Thank you for responding.
 
  Try the following:
  ... you load PrintImage.php into your browser and you'll get a nice
 gray rectangle with the word Works! in the center of it.
   If you don't get that... then you have a problem that is not related
 to path or to PHP per-se...
 
 Wow... thank you so much for providing that code to help me test my
 environment.
 
 I ran your script - with the corrections you provided - and did not get
 the text that says Works!.
 
 I've checked with various fonts, and checked that they worked in
 OpenOffice and other apps, so I don't think fonts are the problem.
 
 As for GD support, phpinfo() it says:
 
 GD Supportenabled
 GD Version2.0 or higher
 FreeType Support  enabled
 FreeType Linkage  with freetype
 FreeType Version  2.1.9
 T1Lib Support enabled
 GIF Read Support  enabled
 GIF Create Supportenabled
 JPG Support   enabled
 PNG Support   enabled
 WBMP Support  enabled
 GetText Support   enabled
 
 Am I missing a necessary module?
 
  Hope this helps
 
 It helps very much. Thank you.
 
 --
 Dave M G
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Writing text into images, and setting text size

2007-12-17 Thread Dave M G

Casey,

Thank you for replying.


Try imagettftext().


I did, as explained:


$font = '/usr/share/fonts/truetype/freefonts/FreeSans.ttf';
$imagettftext($image, 20, 0, $x, $y-10, $textColour, $font, $text);


So my questions remain:


1. 'FreeSans.ttf' is in my /usr/share/fonts/truetype/freefonts
directory. But specifying it doesn't seem to work. How do I get the
system to find the font?

2. I need the scripts I'm writing to be portable, so can I be sure of
what fonts will be available, and will I be able to locate them?

3. I'm not really concerned about what font it is, just that it's large
and readable. If there are other options than what I've explored here,
then I would be open to those too.


Thank you for any advice.

--
Dave M G

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Writing text into images, and setting text size

2007-12-17 Thread Andrés Robinet
 -Original Message-
 From: Dave M G [mailto:[EMAIL PROTECTED]
 Sent: Monday, December 17, 2007 6:47 AM
 To: Casey
 Cc: PHP List
 Subject: Re: [PHP] Writing text into images, and setting text size
 
 Casey,
 
 Thank you for replying.
 
  Try imagettftext().
 
 I did, as explained:
 
  $font = '/usr/share/fonts/truetype/freefonts/FreeSans.ttf';
  $imagettftext($image, 20, 0, $x, $y-10, $textColour, $font, $text);
 
 So my questions remain:
 
  1. 'FreeSans.ttf' is in my /usr/share/fonts/truetype/freefonts
  directory. But specifying it doesn't seem to work. How do I get the
  system to find the font?

I wouldn't. First, I don't know of any standard fonts for linux, though there 
might be (As you have Arial or Times New Roman for windows). Second, It might 
be a safe_mode / open_base_dir issue, or a problem in GD or the freetype 
libraries if the path is right and the font exist.
I would try something like dirname(__FILE__).'/fonts/Arial.ttf'... of course 
that would mean you need to create a fonts directory and copy Arial.ttf from 
your system to that location (violating the copywrite? ;) )... anyway, you can 
check that with any other font.

 
  2. I need the scripts I'm writing to be portable, so can I be sure
 of
  what fonts will be available, and will I be able to locate them?
 

Deploy the fonts along with your scripts... that's the only way I know.

  3. I'm not really concerned about what font it is, just that it's
 large
  and readable. If there are other options than what I've explored
 here,
  then I would be open to those too.

You can get some free fonts, and deploy them along with every project. I do so 
for a custom CAPTCHA script I've made.

 
 Thank you for any advice.
 
 --
 Dave M G
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

Rob


Andrés Robinet | Lead Developer | BESTPLACE CORPORATION
5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 | 
TEL 954-607-4207 | FAX 954-337-2695
Email: [EMAIL PROTECTED]  | MSN Chat: [EMAIL PROTECTED]  |  SKYPE: bestplace |  
Web: http://www.bestplace.biz | Web: http://www.seo-diy.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Writing text into images, and setting text size

2007-12-17 Thread Richard Lynch
On Sun, December 16, 2007 7:59 pm, Dave M G wrote:
 I've been able to write text into an image using the default fonts
 available, with this command:

 ImageString($image, 5, $x - 20,$y-10, $text, $textColour);

 The problem is that the font that is identified by the index 5 is
 too
 small. But it seems that it can't be scaled in any way.

Have you tried 0, 1, 2, 3 and 4?

They are all built-in and different sizes.

 So I thought I would try to specify a font and try something like
 this:

 $font = '/usr/share/fonts/truetype/freefonts/FreeSans.ttf';
 $imagettftext($image, 20, 0, $x, $y-10, $textColour, $font, $text);

 But I'm clearly not doing things quite right, and I have some
 questions:

 1. 'FreeSans.ttf' is in my /usr/share/fonts/truetype/freefonts
 directory. But specifying it doesn't seem to work. How do I get the
 system to find the font?

This should work, according to the docs...

Can the FreeSans.ttf file be read by the PHP user?

 2. I need the scripts I'm writing to be portable, so can I be sure of
 what fonts will be available, and will I be able to locate them?

You are plain out of luck here.
There is NOTHING you can rely on for fonts installed at all, much less
where they will be.
You'd have to package them in with your own software to be safe.

And that may open up licensing/legal issues...

 3. I'm not really concerned about what font it is, just that it's
 large
 and readable. If there are other options than what I've explored here,
 then I would be open to those too.

You could draw the image with a smaller font, and scale the whole
image up...

But that would usually not work well, as the scaling up has to
interpolate pixels, which rarely looks good...

You could also try using:
$font =
imageloadfont('/usr/share/fonts/truetype/freefonts/FreeSans.ttf');
if (!$font){
  error_log(Unable to load font!);
  $font = 5; //fall back to built-in font #5
}
ImageString($image, $font, $x - 20,$y-10, $text, $textColour);

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Writing text into images, and setting text size

2007-12-17 Thread Dave M G

Andrés,

Thank you for responding.


Deploy the fonts along with your scripts... that's the only way I know.
... I do so for a custom CAPTCHA script I've made.


This sounds like a good solution. I'm having a little trouble 
implementing it, however.


I have what I believe is a freely distributable font called 
FreeSans.ttf, and I put it in a directory called fonts in the base 
directory of my site.


However, this seems not to work:

$font = 'fonts/FreeSans.ttf';
imagettftext($image, 20, 0, $x, $y, $textColour, $font, $text);

Putting a slash in front to specify starting from the base directory - 
'/fonts/FreeSans.ttf' - does not seem to work either.


Looking in the manual, it seemed that maybe I needed to set the font 
path with putenv:


$path = realpath('fonts');
putenv('GDFONTPATH=' . $path);

But this yielded no results.

Am I still getting the syntax wrong somehow?

Thank you for any advice.

--
Dave M G

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Writing text into images, and setting text size

2007-12-17 Thread Andrés Robinet
I'm tempted to say that the problem is that the system is not finding the 
font... you'd need to include the full path to the font (and it must be 
readable for the user PHP runs on behalf).

Try the following:

Just for testing put the font and the script that generates the image in the 
SAME directory, so let's say you have something like this:

arial.ttf (-- I just copied it from my windows fonts folder)
PrintImage.php

BOTH IN THE SAME DIRECTORY...
Then, the code for PrintImage.php would look like the following...

?php
//
/* Begin PrintImage.php */

// dirname(__FILE__) means the full path to the directory where this file 
PrintImage.php is sitting
$fontFile = dirname(__FILE__).'/arial.ttf';

$imW = 200;
$imH = 100;
$im = imagecreatetruecolor($imgW, $imgH);
$bgColor = imagecolorallocate($im, 238, 239, 239);
$borderColor = imagecolorallocate($im, 208, 208, 208);
$textColor = imagecolorallocate($im, 46, 60, 31);
$whiteColor = imagecolorallocate($im, 255, 255, 255);
$fontSize = 18;
$textAngle = 0;
$codeString = 'Works!';

// Print rectangle
imagefilledrectangle($im, 0, 0, $imgW, $imgH, $bgColor);
imagerectangle($im, 0, 0, $imW-1, $imH-1, $borderColor);

// Print Text (Calculate Position)
$box = imagettfbbox($fontSize, $fontAngle, $fontFile, $codeString);
$x = (int)($imgW - $box[4]) / 2;
$y = (int)($imgH - $box[5]) / 2;
imagettftext($im, $fontSize, $fontAngle, $x, $y, $textColor, $fontFile, 
$codeString);

// Output... no caching
header(Content-type: image/png);
header(Cache-Control: no-cache, must-revalidate);
header(Expires: Mon, 26 Jul 1997 05:00:00 GMT);
imagepng($im);

/* End PrintImage.php */
/**/
?

Then you know what you do... you load PrintImage.php into your browser and 
you'll get a nice gray rectangle with the word Works! in the center of it. If 
you don't get that... then you have a problem that is not related to path or to 
PHP per-se... maybe it's a GD issue, or the font is broken... or whatever other 
issue... but this code works in windows and linux provided that you get the 
arial.ttf in the same directory as PrintImage.php.

And... use dirname(__FILE__) or similar (meaning ABSOLUTE PATHS), as much as 
possible to reference other files for inclusion or processing... doing 
./myfile.php or ../myfile.php leads to headaches... and usually in the 
moment you can't take a headache (which is project deadlines).

Hope this helps,

Rob
 -Original Message-
 From: Dave M G [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, December 18, 2007 12:31 AM
 To: Andrés Robinet
 Cc: 'PHP List'
 Subject: Re: [PHP] Writing text into images, and setting text size
 
 Andrés,
 
 Thank you for responding.
 
  Deploy the fonts along with your scripts... that's the only way I
 know.
  ... I do so for a custom CAPTCHA script I've made.
 
 This sounds like a good solution. I'm having a little trouble
 implementing it, however.
 
 I have what I believe is a freely distributable font called
 FreeSans.ttf, and I put it in a directory called fonts in the base
 directory of my site.
 
 However, this seems not to work:
 
 $font = 'fonts/FreeSans.ttf';
 imagettftext($image, 20, 0, $x, $y, $textColour, $font, $text);
 
 Putting a slash in front to specify starting from the base directory -
 '/fonts/FreeSans.ttf' - does not seem to work either.
 
 Looking in the manual, it seemed that maybe I needed to set the font
 path with putenv:
 
 $path = realpath('fonts');
 putenv('GDFONTPATH=' . $path);
 
 But this yielded no results.
 
 Am I still getting the syntax wrong somehow?
 
 Thank you for any advice.
 
 --
 Dave M G
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Writing text into images, and setting text size

2007-12-17 Thread Andrés Robinet
Just a correction...

Replace at the beginning of the script (I had some typos, while extracting the 
code from the original script)

 $imW = 200;
 $imH = 100;

By this..

$imgW = 200;
$imgH = 100;

Regards,

Rob


Andrés Robinet | Lead Developer | BESTPLACE CORPORATION
5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 | 
TEL 954-607-4207 | FAX 954-337-2695
Email: [EMAIL PROTECTED]  | MSN Chat: [EMAIL PROTECTED]  |  SKYPE: bestplace |  
Web: http://www.bestplace.biz | Web: http://www.seo-diy.com

 -Original Message-
 From: Andrés Robinet [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, December 18, 2007 1:33 AM
 To: 'Dave M G'
 Cc: 'PHP List'
 Subject: RE: [PHP] Writing text into images, and setting text size
 
 I'm tempted to say that the problem is that the system is not finding
 the font... you'd need to include the full path to the font (and it
 must be readable for the user PHP runs on behalf).
 
 Try the following:
 
 Just for testing put the font and the script that generates the image
 in the SAME directory, so let's say you have something like this:
 
 arial.ttf (-- I just copied it from my windows fonts folder)
 PrintImage.php
 
 BOTH IN THE SAME DIRECTORY...
 Then, the code for PrintImage.php would look like the following...
 
 ?php
 //
 /* Begin PrintImage.php */
 
 // dirname(__FILE__) means the full path to the directory where this
 file PrintImage.php is sitting
 $fontFile = dirname(__FILE__).'/arial.ttf';
 
 $imW = 200;
 $imH = 100;
 $im = imagecreatetruecolor($imgW, $imgH);
 $bgColor = imagecolorallocate($im, 238, 239, 239);
 $borderColor = imagecolorallocate($im, 208, 208, 208);
 $textColor = imagecolorallocate($im, 46, 60, 31);
 $whiteColor = imagecolorallocate($im, 255, 255, 255);
 $fontSize = 18;
 $textAngle = 0;
 $codeString = 'Works!';
 
 // Print rectangle
 imagefilledrectangle($im, 0, 0, $imgW, $imgH, $bgColor);
 imagerectangle($im, 0, 0, $imW-1, $imH-1, $borderColor);
 
 // Print Text (Calculate Position)
 $box = imagettfbbox($fontSize, $fontAngle, $fontFile, $codeString);
 $x = (int)($imgW - $box[4]) / 2;
 $y = (int)($imgH - $box[5]) / 2;
 imagettftext($im, $fontSize, $fontAngle, $x, $y, $textColor, $fontFile,
 $codeString);
 
 // Output... no caching
 header(Content-type: image/png);
 header(Cache-Control: no-cache, must-revalidate);
 header(Expires: Mon, 26 Jul 1997 05:00:00 GMT);
 imagepng($im);
 
 /* End PrintImage.php */
 /**/
 ?
 
 Then you know what you do... you load PrintImage.php into your browser
 and you'll get a nice gray rectangle with the word Works! in the
 center of it. If you don't get that... then you have a problem that is
 not related to path or to PHP per-se... maybe it's a GD issue, or the
 font is broken... or whatever other issue... but this code works in
 windows and linux provided that you get the arial.ttf in the same
 directory as PrintImage.php.
 
 And... use dirname(__FILE__) or similar (meaning ABSOLUTE PATHS), as
 much as possible to reference other files for inclusion or
 processing... doing ./myfile.php or ../myfile.php leads to
 headaches... and usually in the moment you can't take a headache (which
 is project deadlines).
 
 Hope this helps,
 
 Rob
  -Original Message-
  From: Dave M G [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, December 18, 2007 12:31 AM
  To: Andrés Robinet
  Cc: 'PHP List'
  Subject: Re: [PHP] Writing text into images, and setting text size
 
  Andrés,
 
  Thank you for responding.
 
   Deploy the fonts along with your scripts... that's the only way I
  know.
   ... I do so for a custom CAPTCHA script I've made.
 
  This sounds like a good solution. I'm having a little trouble
  implementing it, however.
 
  I have what I believe is a freely distributable font called
  FreeSans.ttf, and I put it in a directory called fonts in the
 base
  directory of my site.
 
  However, this seems not to work:
 
  $font = 'fonts/FreeSans.ttf';
  imagettftext($image, 20, 0, $x, $y, $textColour, $font, $text);
 
  Putting a slash in front to specify starting from the base directory
 -
  '/fonts/FreeSans.ttf' - does not seem to work either.
 
  Looking in the manual, it seemed that maybe I needed to set the font
  path with putenv:
 
  $path = realpath('fonts');
  putenv('GDFONTPATH=' . $path);
 
  But this yielded no results.
 
  Am I still getting the syntax wrong somehow?
 
  Thank you for any advice.
 
  --
  Dave M G
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Writing text into images, and setting text size

2007-12-16 Thread Dave M G

PHP List,

I've been able to write text into an image using the default fonts 
available, with this command:


ImageString($image, 5, $x - 20,$y-10, $text, $textColour);

The problem is that the font that is identified by the index 5 is too 
small. But it seems that it can't be scaled in any way.


So I thought I would try to specify a font and try something like this:

$font = '/usr/share/fonts/truetype/freefonts/FreeSans.ttf';
$imagettftext($image, 20, 0, $x, $y-10, $textColour, $font, $text);

But I'm clearly not doing things quite right, and I have some questions:

1. 'FreeSans.ttf' is in my /usr/share/fonts/truetype/freefonts 
directory. But specifying it doesn't seem to work. How do I get the 
system to find the font?


2. I need the scripts I'm writing to be portable, so can I be sure of 
what fonts will be available, and will I be able to locate them?


3. I'm not really concerned about what font it is, just that it's large 
and readable. If there are other options than what I've explored here, 
then I would be open to those too.


Thank you for any advice.

--
Dave M G

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Writing text into images, and setting text size

2007-12-16 Thread Casey
Try imagettftext().

On Dec 16, 2007 5:59 PM, Dave M G [EMAIL PROTECTED] wrote:
 PHP List,

 I've been able to write text into an image using the default fonts
 available, with this command:

 ImageString($image, 5, $x - 20,$y-10, $text, $textColour);

 The problem is that the font that is identified by the index 5 is too
 small. But it seems that it can't be scaled in any way.

 So I thought I would try to specify a font and try something like this:

 $font = '/usr/share/fonts/truetype/freefonts/FreeSans.ttf';
 $imagettftext($image, 20, 0, $x, $y-10, $textColour, $font, $text);

 But I'm clearly not doing things quite right, and I have some questions:

 1. 'FreeSans.ttf' is in my /usr/share/fonts/truetype/freefonts
 directory. But specifying it doesn't seem to work. How do I get the
 system to find the font?

 2. I need the scripts I'm writing to be portable, so can I be sure of
 what fonts will be available, and will I be able to locate them?

 3. I'm not really concerned about what font it is, just that it's large
 and readable. If there are other options than what I've explored here,
 then I would be open to those too.

 Thank you for any advice.

 --
 Dave M G

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





-- 
-Casey

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] writing text on images

2001-11-27 Thread e c h o p l u s A T w o r k

Hi all,
I've stored on a db using blob fields, the content of some image file.
Ayones know how to write on these image on fly w/o using the filesystem? I
mean:

?
$sql=SELECT file_img FROM ..;

while($val=mysql_fetch_row($select)){
header(Content-type: image/jpeg);
$img=$val[0];
//here I need to write on this $img ... but How can I do?
...
?

many thanks in advance
max




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]