Imagettftext is a function used to write text to an image using TrueType fonts.
Explaining all the parameters involved in this array:
An image resource is returned by one of the image creation functions, such as imagecreatetruecolor(), imagecreatefrompng(), e.t.c.This image is supposed to be an empty certificate.
The font size of the text you intend to place on image.
The angle in degrees, with 0 degrees being left-to-right reading text. Higher values represent a counter-clockwise rotation. For example, a value of 90 would result in bottom-to-top reading text.
X and Y
The x and y axis are use to set the position of the text using the x and y co-ordinates
The color index. we make use of the imagecolorallocate() to set color to the text we are displaying on the image in RGB format.
The path to the TrueType font you wish to use.It could have an extension of .ttf, .otf, e.t.c.
Finally this is the name attributed to the text you intend to display on the image.
This is the major function behind Certificate generator. A good understanding of this would be very useful in other approaches like Id care generator, ticket generator and lots more…
This approach could also be integrated to your websites, so people get certified after performing a specific task like taking a course instead of doing everything manually which would take time.
To get started here are the major stuffs needed
- Font file
- Empty certificate PNG file
- And finally a PHP file where all my codes would be for simplicity.
Note: You can tweak anything once you perfectly understand this code and how this function works.
You can give your file any name, but I would name mine index.php
The index file will contain the form where peoples name would be fetched from and also the PHP code.
Below is the form where data for certificate generation is gotten from.
From the above form we are only getting the name and then the code below is the PHP code
If you have any idea on more things that can be done via this function or any function for uploading image on image.Let's talk on Twitter.
P.s: I'm looking to make new dev friends, lets connect on Twitter.
Thanks for reading 👏