Using PHP’s image functions we can able to add text on a image or a background programmatically using PHP.In this tutorial we will be designing a webform through which you enter the text and create an image file that will have the submitted text. Final Output: Things needed: Background image and font file Here I have used the chunkyfive open type font to style the text.Different fonts can be used by adding otf file. Code: 123456789101112131415161718192021222324<?php // Select the background image $imgPath = 'background.png'; $im = imagecreatefrompng($imgPath); //Font colour $white = imagecolorallocate($im, 255, 255, 255); // Path to font file $font = 'Chunkfive.otf'; // Write it imagettftext($im, 35, 0, 95, 100, $white, $font, '15.7 MBPS'); imagettftext($im, 25, 0, 95, 200, $white, $font, 'Average Internet speed
The post How to add Text to Image using PHP appeared first on Devlup.