Can someone tell me how I would change the font face/size (the font that GD generates on the image) in the following script? The text lines are bolded. I am stumped. I've been googling php/gd tutorials all morning, and nothing I have tried has worked. Any suggestions? Thank you! <?php header("Content-type: image/png"); //This script IS the image. require_once('includes/Config.inc.php'); // Keep the config seperate. require_once('includes/Mysql.inc.php'); // Never forget the MySQL abstraction layer. if(isset($_GET['serial'])){$serial = $_GET[serial];} else{$serial = $default_ticker;} $result = $db->query("SELECT start, end, event, banner, slider FROM Ticker WHERE id='$serial'"); list($start_date, $end_date, $event, $banner_image, $slider_image) = $db->fetch_row($result); $today_date = time(); $current_step = round(((($today_date - $start_date)/60)/60)/24) - 1; $interval = round(((($end_date - $start_date)/60)/60)/24); $remaining = $interval - $current_step; if($remaining == 0){ $string = [B]$event." has arrived!";[/B] }elseif($remaining == 1){ $string = "[B]Only $remaining day left until ".$event[/B]; }else{ $string = "[B]$remaining days until ".$event;[/B] } if(!is_file($banner_image)){ $banner_image = $default_banner_image; //"banners/ruler-10300.png"; } if(!is_file($slider_image)){ $slider_image = $default_slider_image; //"sliders/icon-104.png"; } $banner = imagecreatefrompng($banner_image); $bannerheight = imagesy($banner); $bannerwidth = imagesx($banner); $one_step = (($bannerwidth - 20) / $interval); $black = imagecolorallocate($banner,0,0,0); // Numbers on the bottom of the banner. $count_step = round($interval / 12); $count = $interval; $count2 = 0; while($count>=0){ $px = (($bannerwidth - 20) / $interval) * $count2 + 5; $interval_height = $bannerheight - 25; imagestring($banner, 2, $px, $interval_height,$count, $black); $count = $count - $count_step; $count2 = $count2 + $count_step; } $slider = imagecreatefrompng($slider_image); $sliderheight = imagesy($slider); $sliderwidth = imagesx($slider); $slider_location = $one_step * $current_step + 5 - ($sliderwidth / 2); imagecopy($banner,$slider,$slider_location,0,0,0,$sliderheight,$sliderwidth); $string_height = $bannerheight - 13; $px = (imagesx($banner) - 7.5 * strlen($string)) / 2; imagestring($banner, 3, $px, $string_height, $string, $black); imagepng($banner); imagedestroy($banner); //imagedestroy($slider); ?> Code (markup):
To use font on php images use the function described here And here you'll find a program to generate the font image
Or here using imagettftext function: http://php.mirror.camelnetwork.com/manual/en/function.imagettftext.php - You'll need freetype support on GD.