PDA

View Full Version : PHP draw image...



kevincon
06-23-2009, 08:34 PM
For some reason this doesn't work.

It doesn't show up as an image, except when i save it to the desktop it shows the image...


<?php
require("config.php");
if(isset($_GET['p']))
{
$Id = $_GET['p'];
$Id = mysql_real_escape_string($Id);


$steam = mysql_query("SELECT * FROM users WHERE ID='$Id'") or die ("Error in query".mysql_error());
if (mysql_num_rows($steam) > 0)
{
while($row = mysql_fetch_array($steam))
{
$username = $row["username"];
$money = $row["money"];
}
}
$text = $username." Money: ".$money." ClanNV.com";

$my_img = imagecreate( 450, 25 );
$background = imagecolorallocate( $my_img, 0, 0, 0 );
$text_colour = imagecolorallocate( $my_img, 255, 255, 255 );
imagestring( $my_img, 3, 100, 8, $text ,$text_colour );
imagesetthickness ( $my_img, 5 );


header( "Content-type: image/jpeg" );
imagejpeg( $my_img );
imagecolordeallocate( $text_color );
imagecolordeallocate( $background );
imagedestroy( $my_img );
}else{
$my_img = imagecreate( 450, 25 );
$background = imagecolorallocate( $my_img, 0, 0, 0 );
$text_colour = imagecolorallocate( $my_img, 255, 255, 255 );
imagestring( $my_img, 3, 200, 8, "No user defined",$text_colour );
imagesetthickness ( $my_img, 5 );


header( "Content-type: image/jpeg" );
imagejpeg( $my_img );
imagecolordeallocate( $text_color );
imagecolordeallocate( $background );
imagedestroy( $my_img );
}
?>


Help?



Also how can i write text over a jpeg

I used imagecreatefromjpeg.

Eriksrocks
07-01-2009, 03:17 PM
Do you have a live example?

sac0o01
07-14-2009, 09:00 AM
Also how can i write text over a jpeg

I used imagecreatefromjpeg.

I have been working with multiple coders for over six months to create an application which adds text to a background. It works but has a strong antialias to it.

Go to the GD library homepage and read up on text to image or hit me up here and I will give you a snippet of the code.