Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,149,742 members, 7,806,032 topics. Date: Tuesday, 23 April 2024 at 10:29 AM

Need Help With Some Php Scripts - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Need Help With Some Php Scripts (1269 Views)

I Will Help You Learn Php(scripts, And Tutorials) Fiverr =d / Whois Scripts Is Needed (2) (3) (4)

(1) (Reply) (Go Down)

Need Help With Some Php Scripts by WhoIGoAsk: 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: 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: 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: 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: 4:57am On Jul 08, 2012
done with Content-Disposition: attachment;

(1) (Reply)

I Need A Php Tutor/mentor / Help Designing A Database Table For A Cbt App / Photo Of The Day(for Laughs Only)

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 12
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.