Jump to content

[SOLVED] Need Help With Image Generator


jnerotrix

Recommended Posts

Ok I am Making an ID Card For A Game and I want users to Type in Their account name and it places the text on the card

 

Here is what i need it to do i made this form basically showing what its going to do and what it willl look like after generated is at the bottom

 

 

http://custom-art.110mb.com/idcard/

 

Im just not sure how to do this

 

Thanks,

Jnero

Link to comment
Share on other sites

ok does this code look somewhat correct

 

<?php

$user = $_POST['user'];
$text = $_POST['text'];


$id = imagecreatefrompng("./default.png");


$string = "$user"
$string2 = "$text"
imagestring($id, 5, 20, 10, $string);
imagestring($id, 5, 20, 10, $string2);


header("Content-type: image/png");
imagepng($id);
?> 

Link to comment
Share on other sites

ok edited the code a bit

 

Hows This:

 

<?php

$user = $_POST['user'];
$text = $_POST['text'];
$img = $_POST['picture'];


$id = imagecreatefrompng("./$img");


$string = "$user"
$string2 = "$text"
imagestring($id, 5, 20, 10, $string);
imagestring($id, 5, 20, 10, $string2);


header("Content-type: image/png");
imagepng($id);
?> 

Link to comment
Share on other sites

ok does this code look somewhat correct

 

Hows This:

 

Simple, did it do what you wanted when you tested it?

 

The point of programming is to write code to cause what you want or need to happen. After you write code, you test it. So, during the testing that you did to verify that the code does what you intended, did it?

Link to comment
Share on other sites

Ok I changed The Code a bit But I Get an error here is a new code

 

 

<?php

$user = $_POST['user'];
$img = $_POST['picture'];


$id = imagecreatefrompng("./$img");


$string = $user
imagestring($id, 5, 20, 10, $string); <== This is Line 11

header("Content-type: image/png");
imagepng($id);
?> 

 

This is The error:

Parse error: syntax error, unexpected T_STRING in /www/110mb.com/c/u/s/t/o/m/-/a/custom-art/htdocs/idcard/generatred.php on line 11

Link to comment
Share on other sites

<?php

$user = $_POST['user'];
$img = $_POST['picture'];


$id = imagecreatefrompng("./$img");


$string = $user;
imagestring($id, 5, 20, 10, $string); <== This is Line 11

header("Content-type: image/png");
imagepng($id);
?> 

 

$string = $user;

wasnt closed with a ; try my code above

Link to comment
Share on other sites

Ok I Rebuilt The Code But The Error Just Says

 

The image “http://custom-art.110mb.com/idcard/generatred.php” cannot be displayed, because it contains errors.

 

This is the new Code

 

<?php

header ("Content-type: image/png");
$string = "TEXT";
$font = 4;
$width = imagefontwidth($font) * strlen($string) ;
$height = imagefontheight($font) ;
$im = imagecreatefrompng("./default.png");
$x = imagesx($im) - $width ;
$y = imagesy($im) - $height;
$backgroundColor = imagecolorallocate ($im, 255, 255, 255);
$textColor = imagecolorallocate ($im, 0, 0,0);
$a = imagechar($im, 1, 0, 0);
imagestring ($im, $font, $x, $y, $a, $string, $textColor);
imagepng($im);

?>

Link to comment
Share on other sites

Ok I got it fixed ---

BUT the text just appears on the bottom right how do i place it in a specific spot

 

Heres the fixed code

 

<?php

header ("Content-type: image/png");
$string = "TEXT";
$font = 4;
$width = imagefontwidth($font) * strlen($string) ;
$height = imagefontheight($font) ;
$im = imagecreatefrompng("./default.png");
$x = imagesx($im) - $width ;
$y = imagesy($im) - $height;
$backgroundColor = imagecolorallocate ($im, 255, 255, 255);
$textColor = imagecolorallocate ($im, 0, 0, 0);
imagestring ($im, $font, $x, $y, $string, $textColor);
imagepng($im);

?>

 

 

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.