Adding photo and logo with Data to create Image

Part II of adding MySQL Data from table to Image.
certificate with photo and logo

To the above script we can add QR code, Photo of students and logo to the certificate.

Generating certificates using student photo QR code & logo with data from MySQL table using PHP GD

Adding QR code

How to add QR code to the certificate is explained in MySQL - QR Part III, the part of the code is here.
imagecopyresampled($img_source, $QR, 475, 40 , 0, 0, 100, 100, 100,100);

Adding student photo

We will keep photos of students in one folder photos( download the zip file at the end of this page with sample photos ) . File name of the photos are same as student id like . 1.jpg, 2.jpg .... This is done to maintain unique photos against each student as there is a possibility that name of two students can be same.
imagecopy($img_source,$str, 60, 310 , 0, 0, 100, 100);
We created the path by using file name with directory name in above code and then by using imagecopy() the same is added at a location ( x=60, y=310 ) of the source image.

Adding Logo

If Logo is common in all certificates then it is better to add the same to main template. However to understand the process of adding images dynamically this code is used.
imagecopy($img_source,$str, 280, 50 , 0, 0, 50, 50);
Above codes are kept inside the for loop used to generate certificates of all students by taking data from MySQL student table.
Part 1 : How certificate is prepared by using user input through a HTML form

Download the script and sample template ( image ).
File NameDetails
config-pdo.php PDO Database connection details are stored here.
gd-certificate.php Php script to Generate the image with data, profile photo and logo for each student.
gd-template.jpg The sample template image used to generate the final certificates.
sql_dump.txt SQL Dump to create student table with sample data.
readme.txt Instructions on how to run the script

How QR code is embedded in Certificate ( image ) using MySQL table data
GD functions
Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net

    Applications using GD functions in PHP

    Basic function and application using GD in PHP
    Sin and Cos curve using GD
    Script for Watermarking image on the fly using PHP GD
    Script to generate Captcha using GD with demo
    Getting Image coordinates ( vertical and horizontal ) of points inside a image
    Generating certificates by using templates and user inputs
    Generating certificates by using templates and MySQL table data
    Generating certificates by using templates and MySQL table data with QR code
    Page Hit counter script

    Post your comments , suggestion , error , requirements etc here

    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2022 All rights reserved worldwide Privacy Policy Disclaimer