₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,110 members, 8,420,384 topics. Date: Thursday, 04 June 2026 at 06:17 PM

Toggle theme

Need Help With Some Php Scripts - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingNeed Help With Some Php Scripts (1351 Views)

1 Reply (Go Down)

Need Help With Some Php Scripts by WhoIGoAsk(op): 8:58am On Jul 07, 2012
Hello NL programmers, please i'm trying to use a id card php script that i got from Ibm developers http://www.ibm.com/developerworks/opensource/library/os-php-gamescripts3/
and i'm running into sosme error. I'll appreciate anybody that can help fix this.

<?php

/*
* 3d10-id-card.php
* by Duane O'Brien - http://chaoticneutral.net
* written for IBM DeveloperWorks
*/

if ($_POST) {
putenv('GDFONTPATH=' . realpath('.'));
header('Content-type: image/png');
$img = imagecreatefrompng('IDCard.png');
$black = imagecolorallocate($img, 0, 0, 0);
imagettftext ( $img , 40 , 0 , 600 , 200 , 0 , "tarzeau_-_OCR-A", $_POST['name'] );
imagettftext ( $img , 40 , 0 , 600 , 275 , 0 , "tarzeau_-_OCR-A", $_POST['auth'] );
imagettftext ( $img , 40 , 0 , 600 , 355 , 0 , "tarzeau_-_OCR-A", $_POST['home'] );
imagettftext ( $img , 40 , 0 , 600 , 435 , 0 , "tarzeau_-_OCR-A", $_POST['born'] );
imagettftext ( $img , 40 , 0 , 600 , 510 , 0 , "tarzeau_-_OCR-A", $_POST['hair'] );
imagettftext ( $img , 40 , 0 , 600 , 590 , 0 , "tarzeau_-_OCR-A", $_POST['eyes'] );
imagepng($img);
imagedestroy($img);
} else {
?>
<form method='post'>
Name : <input name='name' /><br />
Auth : <input name='auth' /><br />
Home : <input name='home' /><br />
Born : <input name='born' /><br />
Hair : <input name='hair' /><br />
Eyes : <input name='eyes' /><br />
<input type='submit' value='create id card' />
</form>
<?php

}

?>
Re: Need Help With Some Php Scripts by WhoIGoAsk(op): 9:47am On Jul 07, 2012
the id card test template

Re: Need Help With Some Php Scripts by kadeerna: 10:03am On Jul 07, 2012
Hi, with versions of php_gd2, you have to append a ".ttf" to the font name passed to the imagettftext function.(http://php.net/manual/en/function.imagettftext.php) So your code becomes:


...
imagettftext ( $img , 40 , 0 , 600 , 200 , 0 , "tarzeau_-_OCR-A.ttf", $_POST['name'] );
imagettftext ( $img , 40 , 0 , 600 , 275 , 0 , "tarzeau_-_OCR-A.ttf", $_POST['auth'] );
imagettftext ( $img , 40 , 0 , 600 , 355 , 0 , "tarzeau_-_OCR-A.ttf", $_POST['home'] );
imagettftext ( $img , 40 , 0 , 600 , 435 , 0 , "tarzeau_-_OCR-A.ttf", $_POST['born'] );
imagettftext ( $img , 40 , 0 , 600 , 510 , 0 , "tarzeau_-_OCR-A.ttf", $_POST['hair'] );
imagettftext ( $img , 40 , 0 , 600 , 590 , 0 , "tarzeau_-_OCR-A.tff", $_POST['eyes'] );
...


Also, the font file "tarzeau_-_OCR-A" has to be in the same directory from the one this script is run from.

Needless to add, you can remove the font file to a variable.


$font = "tarzeau_-_OCR-A.ttf"
...
imagettftext ( $img , 40 , 0 , 600 , 590 , 0 , $font, $_POST['eyes'] );
...
Re: Need Help With Some Php Scripts by WhoIGoAsk(op): 10:29am On Jul 07, 2012
Thanks Kadeerna, i'll try it again as you explained, and will surely leave a feedback here for other programmers

Regards
Re: Need Help With Some Php Scripts by WhoIGoAsk(op): 2:16am On Jul 08, 2012
it worked, though i had to change the font file. the next challenge is adding a save image button to the output image
Re: Need Help With Some Php Scripts by WhoIGoAsk(op): 4:57am On Jul 08, 2012
done with Content-Disposition: attachment;
1 Reply

I Will Help You Learn Php(scripts, And Tutorials) Fiverr =dWhois Scripts Is Needed234

ForumAre You Software Dealer Or A Programmer?Botnet For Sale