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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.