Php - How to write text in a image using php, Writing some text on jpeg image using php
How to write text in a image using php
header('Content-type: image/jpeg'); $text = "TechBluff!"; # sample text to be used in a jpeg picture. $font = 'ambient.ttf'; # font style $image = imagecreatefromjpeg('watermark.jpg'); # sample image where the text to be used. $text_col= imagecolorallocate($image, 255, 255, 255); #color of the text. imagettftext($image, 125, 0, 975, 220, $text_col, $font, $text); # using text in a image. /* Parameter usage in imagettftext function: 1.the first parameter represents the image to be used.(i.e., image). 2.the second parameter represents the font size.(i.e., 125). 3.the third parameter represents the angle of the text to be displayed.(i.e., 0). 4.the fourth parameter represents the x position.(i.e., 975). 5.the fifth parameter represents the y position.(i.e., 220). 6.the sixth parameter represents the text color. 7.the seventh parameter represents the font file. 8. the eighth parameter represents the text to be used in image. */ imagejpeg($image); imagedestroy($image);
Some times this can be used as your own watermark images and store them in your database. Above is asimple code to create an image with your any text and the image is destroyed at the end.
The topic on Php - How to write text in a image using php is posted by - Guru
Hope you have enjoyed, Php - How to write text in a image using phpThanks for your time