imgecreate probs

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
bimo
Forum Contributor
Posts: 100
Joined: Fri Apr 16, 2004 11:18 pm
Location: MD

imgecreate probs

Post 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;
?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
choppsta
Forum Contributor
Posts: 114
Joined: Thu Jul 03, 2003 11:11 am

Post 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]">
User avatar
bimo
Forum Contributor
Posts: 100
Joined: Fri Apr 16, 2004 11:18 pm
Location: MD

Post by bimo »

Thank you both.
Post Reply