Page 1 of 1

imgecreate probs

Posted: Fri Jun 04, 2004 12:59 am
by bimo
I am trying to do something that seems like it should be possible but I need to dnamically create images to make it possible.

What I am doing is simple: print all the unicode characters. However, I want there to be alt tags on each character so that I can see what the char's hexidecimal representation is when the mouse cursor hovers over it.

I figured that I could use imagecreate() to make the character into an image with an alt tag but I'm having problems with the imagestring() function. Actually, I think right now, I have some stupid syntactical error that's preventing my code from working. below is the code.

Also, does the GD font support all the characters that I'm looking for?

Thanks, holly

Code: Select all

<?php
$a = 0;
$b = 0;
$c = 0;
$d = 0;
$i = 0;
for($count = 0; $count <= 50000; $count++) &#123;
	$i = dechex($count);
	$iToUnicode = "&#x$i;";
	$imgNum = "\$img$i";
	$textColor = "#000000";
	$row = $count / 35;
	//$col = (($i / 6) + 1;
	$rowX = $row + 6 + (6 * $row);
	$rowY = $row + 6 + ($i  );
	//ImageString($imgNum, 3, 
	$theIm = imagestring($imgNum, 4, $rowX, $rowY, "$iToUnicode", $textColor);
	print("<img src=$theIm alt=$i>");
	//print("&#x$i;</a> | ");
	
	if(!$count % 34) print("<br>");
	
	
	
&#125;
?>

Posted: Fri Jun 04, 2004 1:56 am
by feyd
to print all unicode characters, you don't need GD.. at least in some browsers/OS's...

It looks like your code will write a raw binary to the html stream.. which won't get you anywhere.

Posted: Fri Jun 04, 2004 3:21 am
by choppsta
Firstly, if all you need is to have an "alt tag" with each character, you could try something like:

<span title="[hex value]">[unicode character]</span>

I think the title attribute is intepreted by most browsers as an alt tag. Infact I think it's only really IE that intepretes alt as a "popup hint", but they all seem to respond to title in a similar way.

Secondly, as feyd has said, you are writing out HTML and the image data at the same time, which ain't going to work.
Probably the easiest way to do it would be to have a seperate script that just outputs an image based on the querystring.
Then in your main script you can just output image tags such as:

<img src="characterImage.php?character=[character]" title="[hex]" alt="[hex]">

Posted: Fri Jun 04, 2004 9:41 am
by bimo
Thank you both.