Skip to content

Instantly share code, notes, and snippets.

@olawanlejoel
Created February 14, 2020 12:41
Show Gist options
  • Save olawanlejoel/889eeb7c46fff39a35295ee71063d6e1 to your computer and use it in GitHub Desktop.
Save olawanlejoel/889eeb7c46fff39a35295ee71063d6e1 to your computer and use it in GitHub Desktop.
<?php
if (isset($_POST['generate'])) {
$name = strtoupper($_POST['name']);
//designed certificate picture
$image = "certi.png";
$createimage = imagecreatefrompng($image);
//this is going to be created once the generate button is clicked
$output = "certificate.png";
//then we make use of the imagecolorallocate inbuilt php function which i used to set color to the text we are displaying on the image in RGB format
$white = imagecolorallocate($createimage, 205, 245, 255);
$black = imagecolorallocate($createimage, 0, 0, 0);
//Then we make use of the angle since we will also make use of it when calling the imagettftext function below
$rotation = 0;
//we then set the x and y axis to fix the position of our text name
$origin_x = 200;
$origin_y=260;
$font_size = 10;
$certificate_text = $name;
//font directory for name
$drFont = dirname(__FILE__)."/developer.ttf";
//function to display name on certificate picture
$text1 = imagettftext($createimage, $font_size, $rotation, $origin_x, $origin_y, $black, $drFont, $certificate_text);
imagepng($createimage,$output,3);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment