items)){ $item = array_slice($rss->items, 0, 1); $text = $item[0][title]; $text = substr($text, strlen($twitter_user_name)+2); $text = wordwrap ($text, 43, "\n", 1); $text = explode("\n", $text); $height = ($line_height * count($text)) + ($line_height*2); // Create the image $im = imagecreatetruecolor( 330, $height ); // Create some colors $bg = imagecolorallocate($im, 0, 0, 0); imagecolortransparent($im, $bg); $fg1 = imagecolorallocate($im, 255, 255, 255); $fg0 = imagecolorallocate($im, 153, 153, 153); $fg2 = imagecolorallocate($im, 102, 102, 102); imagefilledrectangle($im, 0, 0, $width - 1, $height - 1, $bg); // Add the text imagettftext($im, 12, 0, 111, 18, $fg0, $font, "Current Status:"); for ($i=0;$i <= count($text);$i++) { $x = round( 165 - ((strlen($text[$i])*7.7) / 2) ); $y = 18 * ($i+2); imagettftext($im, 12, 0, $x, $y, $fg1, $font, $text[$i]); } # relative dates $then = @parse_w3cdtf($item[0]['published']); $now = time(); $diff = $now - $then; $months = floor($diff/2592000); $diff -= $months*2419200; $weeks = floor($diff/604800); $diff -= $weeks*604800; $days = floor($diff/86400); $diff -= $days*86400; $hours = floor($diff/3600); $diff -= $hours*3600; $minutes = floor($diff/60); $diff -= $minutes*60; $seconds = $diff; if ($months>0) { // over a month old, just show date $dateline = "on " . date('F jS, Y', $then); } else { if ($weeks>0) { // weeks and days $relative_date .= ($relative_date?', ':'').$weeks.' week'.($weeks>1?'s':''); $relative_date .= $days>0?($relative_date?', ':'').$days.' day'.($days>1?'s':''):''; } elseif ($days>0) { // days and hours $relative_date .= ($relative_date?', ':'').$days.' day'.($days>1?'s':''); } elseif ($hours>0) { // hours and minutes $relative_date .= ($relative_date?', ':'').$hours.' hour'.($hours>1?'s':''); } elseif ($minutes>0) { // minutes only $relative_date .= ($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':''); } else { // seconds only $relative_date .= ($relative_date?', ':'').$seconds.' second'.($seconds>1?'s':''); } } // show relative date and add proper verbiage $dateline = "posted " . $relative_date.' ago'; imagettftext($im, $font_size_in_points, 0, (327 - round(strlen($dateline)*$font_em_in_pixels)), ($font_size_in_pixels * ($i+1)), $fg2, $font, $dateline); // Using imagepng() results in clearer text compared with imagejpeg() imagepng($im); imagedestroy($im); } ?>