Netscape 4.7 with php gd, very slow
| From: | Harry Yu | Date: | Fri, 26 Jul 2002 14:09:36 +0000 |
| Subject: | Netscape 4.7 with php gd, very slow | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-109729@lists.php.net to get a copy of this message | ||
Hi all,
I'm trying to generate dynamic buttons with text from mysql database.
Everything is fine except that the images are displaying very slow in
Netscape 4.7. Internet Explorer, Netscape 6 and Mozilla are very fast. I'm
running Apache 1.3.26, PHP 4.2.2, GD 1.6.2 on Linux. Also, I have the same
scripts running in Windows 2000 and I don't have this problem with Netscape.
The following are the scripts:
image.php:
<?
$s = $_GET[s];
$text = $_GET[text];
$fontfile = "bonzai.ttf";
Header("Content-type: image/png");
if(!isset($s)) $s=11;
$size = imagettfbbox($s,0,$fontfile,$text);
$dx = abs($size[2]-$size[0]);
$dy = abs($size[5]-$size[3]);
$xpad=5;
$ypad=5;
$im = imagecreate($dx+$xpad,$dy+$ypad);
$white = ImageColorAllocate($im, 255,255,255);
$red = ImageColorAllocate($im, 255,0,0);
$black = ImageColorAllocate($im, 0,0,0);
ImageTTFText($im, $s, 0, (int)($xpad/2)-1, $dy+(int)($ypad/2)-1, $black,
$fontfile, $text);
ImagePNG($im);
ImageDestroy($im);
?>
button.php:
<html>
<body topmargin="5" leftmargin="5" marginheight="5"
marginwidth="5"
bgcolor="#FAFAFA">
<table border="0" bgcolor="#FBE2AA" cellpadding="0"
cellspacing="0"
width="100%">
<td>
<table border="0" cellpadding="2" cellspacing="2"
width="100%"
bgcolor="#FBE2AA">
<tr bgcolor="#FFFFFF"><td>
<table border="0" cellpadding="0" cellspacing="0">
<?php
mysql_connect ( "server", "user", "password" );
mysql_select_db ( "table" );
$query = mysql_query ( "select distinct text from images" );
while ( $result = mysql_fetch_array ( $query ) ) {
$text = urlencode ( $result[text] );
echo "<tr><td><img src=\"image.php?s=14&text=$text\"
border=\"0\"></td>";
}
?>
</table>
</td></tr>
</table>
</td>
</table>
</body>
</html>
Has anyone experience this problem before? I'm not sure whether Apache,
PHP, or GD is causing this.
Thanks,
Harry