Re: generate img with fonts...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yes yes, you guys are hilarious but at least try to answer his question! :)

Bobo, I assume you're using Win32 and true type fonts, try this chunk of
code:

You *will* need to install freetype  (www.freetype.org) and enable gd/gd2
(depending on your version of php) extensions on your php install.

ref: http://www.php.net/manual/en/function.imagettftext.php

<?php
Header("Content-type: image/jpeg");
$outputtext = "Welcome";
$fontfilename = "BlissIf Caps BoldItalic.ttf"; // whatever the actual
filename is called
$im = ImageCreate(240, 30);
$black = ImageColorAllocate($im, 0, 0, 0);
$white = ImageColorAllocate($im, 255, 255, 255);
if (strpos(strtoupper($HTTP_SERVER_VARS["SERVER_SOFTWARE"]),"WIN",0)
=== false) {
   /* UNIX OS, use unix style paths and fontsize */
   $fontsize = 60;
   $fontpath = "/usr/local/apache/htdocs/fonts/";
} else {
   /* Windows OS, use windows style paths and fontsize */
   $fontsize = 8;
   $fontpath = 'C:\\windows\fonts\\';
}
ImageTTFText($im, $fontsize, 0, 20, 20, $white, $fontpath. $fontfilename,
$outputtext);
ImageJpeg($im);
ImageDestroy($im);
?>

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


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux