mattal999 Posted October 3, 2007 Share Posted October 3, 2007 is there any way to turn: http://www.games4uonline.com/drag/gamercard.php?username=mattal999 into a picture online? using php? thanks Link to comment https://forums.phpfreaks.com/topic/71689-solved-text-to-image/ Share on other sites More sharing options...
mattal999 Posted October 3, 2007 Author Share Posted October 3, 2007 anyone? Link to comment https://forums.phpfreaks.com/topic/71689-solved-text-to-image/#findComment-361010 Share on other sites More sharing options...
MadTechie Posted October 3, 2007 Share Posted October 3, 2007 yes. read the page in and filter the data you want (RegEx) then create an image from it image example <?php header("Content-type: image/png"); $im = @imagecreate(110, 20) or die("Cannot Initialize new GD image stream"); $background_color = imagecolorallocate($im, 0, 0, 0); $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 1, 5, 5, "A Simple Text String", $text_color); imagepng($im); imagedestroy($im); ?> Link to comment https://forums.phpfreaks.com/topic/71689-solved-text-to-image/#findComment-361017 Share on other sites More sharing options...
mattal999 Posted October 3, 2007 Author Share Posted October 3, 2007 yes, that would work, but is there an easier waY? like take a screenshot and then crop it and put it on the screen? that would b so much easier! Link to comment https://forums.phpfreaks.com/topic/71689-solved-text-to-image/#findComment-361059 Share on other sites More sharing options...
MadTechie Posted October 3, 2007 Share Posted October 3, 2007 sure.. you could do that.. (manually) (not with a standard php setup) and to have it run automatically would be slower and cost more to run.. and in the long run, probably not easier... Link to comment https://forums.phpfreaks.com/topic/71689-solved-text-to-image/#findComment-361062 Share on other sites More sharing options...
mattal999 Posted October 3, 2007 Author Share Posted October 3, 2007 well, is there a way to add a premade background? into the php made picture? Link to comment https://forums.phpfreaks.com/topic/71689-solved-text-to-image/#findComment-361070 Share on other sites More sharing options...
MadTechie Posted October 3, 2007 Share Posted October 3, 2007 try this <?php header("Content-Type: image/jpeg"); $im = @imagecreatefromjpeg("test.jpg"); imagestring($im, 1, 5, 5, "A Simple Text String", $text_color); imagejpeg($img); ?> Link to comment https://forums.phpfreaks.com/topic/71689-solved-text-to-image/#findComment-361078 Share on other sites More sharing options...
mattal999 Posted October 3, 2007 Author Share Posted October 3, 2007 look at the comparison: http://games4uonline.com/drag/gamercard.php?username=mattal999 and here is the code to card.php: <?php session_start(); include 'connect.php'; $username = $_GET['username']; $drag1="SELECT * from dragusers WHERE username='$username'"; $drag2=mysql_query($drag1) or die("Could not select car."); $drag3=mysql_fetch_array($drag2); $im = @imagecreatefromgif('card.GIF') or die("Cannot Initialize new GD image stream"); $background_color = imagecolorallocate($im, 255, 255, 255); $text_color = imagecolorallocate($im, 56, 56, 56); $text_blue = imagecolorallocate($im, 30, 144, 255); header("Content-type: image/png"); imagestring($im, 2, 11, 7, "" . $username . "", $text_blue); imagestring($im, 2, 38, 25, "" . $drag3[car] . "", $text_color); imagestring($im, 2, 55, 38, "" . $drag3[engine] . "L (" . $drag3[enginel] . ")", $text_color); imagestring($im, 2, 54, 50, "" . $drag3[credits] . "", $text_color); imagestring($im, 2, 75, 62, "" . $drag3[races] . "", $text_color); imagepng($im); imagedestroy($im); ?> can you try and change the font to 'Bold 10px verdana' and can you try and make the text on the right? Thanks P.S. The car names will be different lengths! Link to comment https://forums.phpfreaks.com/topic/71689-solved-text-to-image/#findComment-361146 Share on other sites More sharing options...
marcus Posted October 3, 2007 Share Posted October 3, 2007 You're going to need to use imagettftext and load Verdana yourself. Link to comment https://forums.phpfreaks.com/topic/71689-solved-text-to-image/#findComment-361151 Share on other sites More sharing options...
cooldude832 Posted October 3, 2007 Share Posted October 3, 2007 fyi taking a screenshot and then using that would be 1000 times more work than generating your own image. Link to comment https://forums.phpfreaks.com/topic/71689-solved-text-to-image/#findComment-361155 Share on other sites More sharing options...
MadTechie Posted October 3, 2007 Share Posted October 3, 2007 personally i would use imagestring for all the text, as for changing the font you need to use imageloadfont() or imagettftext, but i don't think you can justify the text (i think not)..your best best is probably padding Link to comment https://forums.phpfreaks.com/topic/71689-solved-text-to-image/#findComment-361157 Share on other sites More sharing options...
mattal999 Posted October 3, 2007 Author Share Posted October 3, 2007 well, ive managed to get the verdana in there, but how can i make it bold? Link to comment https://forums.phpfreaks.com/topic/71689-solved-text-to-image/#findComment-361165 Share on other sites More sharing options...
MadTechie Posted October 3, 2007 Share Posted October 3, 2007 either use the bold font from the verdana family or emulate it This function will make your text bold: <?php function drawboldtext($image, $size, $angle, $x_cord, $y_cord, $r, $g, $b, $fontfile, $text) { $color = ImageColorAllocate($image, $r, $g, $b); $_x = array(1, 0, 1, 0, -1, -1, 1, 0, -1); $_y = array(0, -1, -1, 0, 0, -1, 1, 1, 1); for($n=0;$n<=8;$n++) { ImageTTFText($image, $size, $angle, $x_cord+$_x[$n], $y_cord+$_y[$n], $color, $fontfile, $text); } } ?> Link to comment https://forums.phpfreaks.com/topic/71689-solved-text-to-image/#findComment-361167 Share on other sites More sharing options...
mattal999 Posted October 3, 2007 Author Share Posted October 3, 2007 i dont seem to have the 'verdana bold' font... and that function makes it way too large! i tried that when i made it into verdana... Link to comment https://forums.phpfreaks.com/topic/71689-solved-text-to-image/#findComment-361171 Share on other sites More sharing options...
marcus Posted October 3, 2007 Share Posted October 3, 2007 You should just use the Verdana-Bold TTF. http://neoblob.com/verdanab.ttf Link to comment https://forums.phpfreaks.com/topic/71689-solved-text-to-image/#findComment-361172 Share on other sites More sharing options...
mattal999 Posted October 3, 2007 Author Share Posted October 3, 2007 sorted, have a look at it now! It looks awesome! Thanks guys Link to comment https://forums.phpfreaks.com/topic/71689-solved-text-to-image/#findComment-361188 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.