slyte33 Posted October 15, 2009 Share Posted October 15, 2009 Hello, i've just signed up and will probably start coming here a lot. I've read a bit on the forums and like what I see I am curious is to how I could implant the number of players on my game, with an image. I DO have the script to make an image but what I want is actually more complex than what you are thinking. First examine this image: Where it says Players, i'd like it to display the amount of players, but with with a font that looks the same way as the players. I can easily create 0, 1, 2, 3... etc up to 9 to have this. I use ADODB which makes coding much easier, so if I were to make this image, i would go along with: $query = $db->execute("select * from players"); $count = $query->recordcount(); Then in the file that I already have the script made on, i would probably add something like this: imagestring($image, 3, 115, 15, "$count", white); If it is simply not possbile to add the numbers with the same font as the word "PLAYERS" then that is fine, but the next question would be.. How do I make the image I made in php be the background of the banner above? I've tried a lot and cannot seem to change anything except the background image of the picture. I hope I can be a good part of this community one day, and will start visiting here often. All help on this is MUCH appreciated! Thanks! Link to comment https://forums.phpfreaks.com/topic/177742-solved-creating-image-with-php/ Share on other sites More sharing options...
Garethp Posted October 15, 2009 Share Posted October 15, 2009 http://www.php.net/manual/en/function.imagettftext.php That lets you use a ttf font file for the font of text Link to comment https://forums.phpfreaks.com/topic/177742-solved-creating-image-with-php/#findComment-937207 Share on other sites More sharing options...
slyte33 Posted October 15, 2009 Author Share Posted October 15, 2009 How would I make the banner the main background image, as if it was a normal .gif image and not a .php file? Thanks for feedback Link to comment https://forums.phpfreaks.com/topic/177742-solved-creating-image-with-php/#findComment-937217 Share on other sites More sharing options...
Garethp Posted October 15, 2009 Share Posted October 15, 2009 Why don't you post the code you currently have, and then fully explain what you mean by as a gif not a php file Link to comment https://forums.phpfreaks.com/topic/177742-solved-creating-image-with-php/#findComment-937336 Share on other sites More sharing options...
Robbrad Posted October 15, 2009 Share Posted October 15, 2009 You need to use your .htaccess file and apache mod rewrite to re write requests to the gif file to go to the php file something like... RewriteEngine On RewriteBase / RewriteRule ^image.gif image.php? [QSA] http://www.workingwith.me.uk/articles/scripting/mod_rewrite Link to comment https://forums.phpfreaks.com/topic/177742-solved-creating-image-with-php/#findComment-937434 Share on other sites More sharing options...
slyte33 Posted October 16, 2009 Author Share Posted October 16, 2009 Ok here is my code, this will simply show the number of players in the center of a 280 by 50px box, with a transparent background. My goal is to show these players in the banner listed above: <?php include("lib.php"); $player = check_user($secret_key, $db); $totplayers = $db->execute("select * from players"); $players = $totplayers->recordcount(); $image = imagecreatetruecolor(280, 50); $red = imagecolorallocate($image, 255, 0, 0); $black = imagecolorallocate($image, 0, 0, 0); // Make the background transparent imagecolortransparent($image, $black); $text_color = imagecolorallocate($image, 0, 0, 0); $white = ImageColorAllocate($image,255,255,255); $blue = imagecolorallocate($image, 0, 0, 255); $red = imagecolorallocate($image, 0 , 200, 0); $bg = imagecolorallocate($image, 255, 255, 255); $textcolor = imagecolorallocate($image, 1, 1, 1); imagestring($image, 3, 115, 15, "$players", $textcolor); header('Content-type: image/png'); imagepng($image); imagedestroy($image); ?> Link to comment https://forums.phpfreaks.com/topic/177742-solved-creating-image-with-php/#findComment-938145 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.