How to generate certificate in PHP?
To generate certificate we need three major things:
- Font File
- Empty certificate PNG/JPG file
- PHP file where all my codes written
create a php file with any name. In my case I would name mine index.php
GD library should be enable. you can just remove ; to enable in php.ini file
<?php header('Content-type: image/jpeg'); //add font in root directory $font=realpath('arial.ttf'); //add your image/certificate file $image=imagecreatefromjpeg("format.jpg"); $color=imagecolorallocate($image, 51, 51, 102); $date=date('d F, Y'); imagettftext($image, 18, 0, 880, 188, $color,$font, $date); //Add your desire text $name="YOUTUBE"; imagettftext($image, 48, 0, 120, 520, $color,$font, $name); //download //imagejpeg($image,"certificate/$name.jpg"); //preview imagejpeg($image); imagedestroy($image); ?>