Jump to content

[SOLVED] Text to Image


mattal999

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.