This is my own code and working well! Just change the name of name.jpg to the file name what you want:
My code is a little different with yours, one of different is You didn't change the place of pointer, the place that you are going to put your character I mean the $x:
imagettftext[$jpg_image, 30, 0, $x, 200, $white, $font_path, $print_text];
And another different is character, You gave the string [not character] to the imagettftext function, But I give one character. I think character is better than string In particular to creating captcha.
Last Updated : Apr 15, 2022
IN - PHP PHP GD
In this tutorial we will show you how to add text to images using PHP GD library.The text can be any text like your name, web address, email or your number.You may also like add watermark to an image using PHP.
Join With 27,000+ Members In Our Google Group & Get Latest Tutorials
Get our latest tutorials, How-To guides on web development every day right into your inbox.
To Add Text To Image It Takes Only One Step:-
- Make a PHP file and define scripting
Step 1. Make a PHP file and define scripting
We make a PHP file and save it with a name text_to_image.php
In this step we first set the image header to return image after processing.Then we load the image from directory and create that image using imagecreatefromjpeg[] function then we allocate the color.
We use white color in text so we use RGB value of white you can use any color RGB value, then we specify font path it is very important to add font path because without using font your text will not be visible you can use any font for your text.
Then we set the text and use imagettftext[] function to add text to images you can also customise the size, angle and position of the text as per your need.You may also like display text over image.
Thats all, this is how to add text on images using PHP and php gd library.You can customize this code further as per your requirement. And please feel free to give comments on this tutorial.
Latest Tutorials
- Create Animated Skill Bar Using jQuery, HTML And CSS
- Simple And Best Responsive Web Design Using CSS Part 2
- Show Button On Hover Using HTML And CSS
- Material Design Login Form Using jQuery And CSS
- Animated Progress Bar Using jQuery And CSS
- Dynamic Drop Down Menu Using jQuery, Ajax, PHP And MySQL
- Get Website Statistics Using PHP, jQuery And MySQL
- HTML5 Login And Signup Form With Animation Using jQuery
- Facebook Style Homepage Design Using HTML And CSS
- View Webpage In Fullscreen Using jQuery
In this example I am going to explain to you how to add text to a certificate image with GD with GD library.