Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,031 members, 7,807,060 topics. Date: Wednesday, 24 April 2024 at 09:04 AM

Create Png ID Card With Database Info With PHP - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Create Png ID Card With Database Info With PHP (7532 Views)

Double Your Sales With Database Bulksms / Auto Post On Facebook With PHP Script / Please Help Me With Php Code To Submit Picture To Database (2) (3) (4)

(1) (Reply) (Go Down)

Create Png ID Card With Database Info With PHP by seborne(m): 12:10pm On Feb 10, 2015
Hi guys,
I would like to create an image ID card that is populated with
details from MySQL Database.
Can anyone kindly point me in the right direction.
Thanks
Re: Create Png ID Card With Database Info With PHP by adewasco2k(m): 7:52pm On Feb 10, 2015
You not asking for codes right?

This is how i expect you to do this.

1. create a template of the ID CARD on photoshop ...save in png...use as for web
2. use imagecreatefrompng() to write your text on the template
3. come back and say thank you

2 Likes

Re: Create Png ID Card With Database Info With PHP by seborne(m): 11:55pm On Mar 03, 2015
adewasco2k:
You not asking for codes right?

This is how i expect you to do this.

1. create a template of the ID CARD on photoshop ...save in png...use as for web
2. use imagecreatefrompng() to write your text on the template
3. come back and say thank you

Ho Adewasco2k! It worked and i'm back to say a big Thank You!!!
Re: Create Png ID Card With Database Info With PHP by adewasco2k(m): 11:32pm On Mar 04, 2015
seborne:


Ho Adewasco2k! It worked and i'm back to say a big Thank You!!!
That was nice of you
Re: Create Png ID Card With Database Info With PHP by Nobody: 8:41pm On Mar 05, 2015
@adewasco.

That seem not right at all. How do you work on 5,000 id cards with that?
Re: Create Png ID Card With Database Info With PHP by adewasco2k(m): 11:26pm On Mar 06, 2015
PietraK:
@adewasco.

That seem not right at all. How do you work on 5,000 id cards with that?

maybe you didnt get it well.

because there is not going to be any problem even working on 1 million ID cards

if you dont get it...tell me i will explain better
Re: Create Png ID Card With Database Info With PHP by Nobody: 6:35am On Mar 07, 2015
adewasco2k:


maybe you didnt get it well.

because there is not going to be any problem even working on 1 million ID cards

if you dont get it...tell me i will explain better
Pls I didn't get you.
Op said the card pin will be populated from database.now I want was it ur step 2 explanation above that will populate the info from the database into card info ?

By the wat do u mean by : imagecreatefrompng()? Is a script command
Re: Create Png ID Card With Database Info With PHP by Nobody: 7:36pm On Mar 16, 2015
@adewasko...

I don't understand your explanation, but I am sure it won't solve the Ops problem.

how do you pull details from database with your explanation, and the OP thanking you seem to cause more confusion. How on earth did that solve his problem?

Explain better...
Re: Create Png ID Card With Database Info With PHP by adewasco2k(m): 8:35pm On Mar 16, 2015
PietraK:
@adewasko...

I don't understand your explanation, but I am sure it won't solve the Ops problem.

how do you pull details from database with your explanation, and the OP thanking you seem to cause more confusion. How on earth did that solve his problem?

Explain better...
hahahaha...really?

I will try to explain this again, mind you i have personally done this severally either with pure php or javascript, but lets stick to php.


1. Get the template of the ID card: Just get the ID card designed and save it in any format but lets stick to PNG format.


2. Manipulate the template by typing in and placing photo on it using php

lets assume you have gotten the name, age, sex etc of the person dynamically.

$name = "Wilson Adewale Akinola";
$age = 26;
$sex ="Male";

and your template is saved on a path at /path/images/ID_Card_template.png


There are alot of PHP's image manipulation functions but you can read more...i havent used many...i do check php.net mostly for them, so:

$new_card = imagecreatefrompng("/path/images/ID_Card_template.png"wink;
$font_size = 16;
$name;
$age;
$sex;
$angle =0; //The angle in degrees, with 0 degrees being left-to-right reading text.

then set the color of the texts that will be written on the template, i will use black for example

$color = imagecolorallocate($new_card, 0, 0, 0);

Now the tricky path is getting the position of spaces to write the text...so that the name will appear on the space with name:

really i do trial n error till i get the exact position (there is a wise way around this but i only know how to in javascript grin havent tried it in php)

$x =;// x-coordinate of the upper left corner.....find where the text will be placed
$y =; // y-coordinate of the upper left corner....find where the text will be placed

This is the function to now use:


imagestring ( $new_card , $font_size , $x , $y , $name , $color );

Header('Content-type: image/png');

imagepng($new_card); //this will output your ID CARD template with the name Wilson Adewale Akinola at the postion of $x and $y coordinates"

what i will expect is you create a function to loop through the available variables (name, age, sex etc using imagestring() and place each variable at different position and boom you have your ID CARD populated with details from database).

save the new image in a new directory and keep uusing same one template for others.....you can create thousands of ID cards within few minutes grin

// clear up the text
imagedestroy($new_card);

Note:

php GD library must be installed on your server for you to be able to use any image manipulation functions in php
Re: Create Png ID Card With Database Info With PHP by Nobody: 9:31pm On Mar 16, 2015
Now you are talking.

I have something like that..... for our over 15,000 members....

(1) (Reply)

6 Mistakes That Can Kill Your Blog / Factors To Consider When Choosing A Host Service Provider. / 5 Reasons Why Many Bloggers Choosed Blogger Over Wordpress

(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. 20
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.