Text to Image Convert using php code . Download source Code

Create and save dynamic image in php using gd library

Hi Geeks,
In this tutorial we will learn that how to Create and save dynamic image in php using gd library or Text to Image Convert using php code . in this example we have a requirement to create a image with specific width and height and specific background and watermark also.
So that we have created a PHP Class to generate and save the image to specific folder or path.
please follow the steps to achive this task.
Step 1. Create a class file for generate image with name class.img.php with following code:

Step 2. make another php file with any name.
and include the class file as follow:

Now create a instance of img class with font file names and sizes as following :

Init with font files and font sizes as follow:

Now generate a single image as follow:

Generate multiple images in loop as following code :

Complete Code of above snippets:

Note: please confirm GD library on your php server. and create a images folder in project with 755 or 775 or 777 permissions.


You May Also Like

About the Author: Admin

We are the Web Developer, technical writer and a blogger from jaipur and worked with PHP,Mysql,JavaScript,Node Js,Angular Js,Jquery,JQuery Mobile,.Net,Sql Server etc., but his language of choice is PHP & JAVASCRIPT. You can learn more and discussion with us at w3school