I am using following PHP code to write text with the background color on the image using PHP code.
But it's adding the text with the background color on the image. I need to add the text to background color below the image. How can I do this with PHP?
PHP code:
// Create Image From Existing File
$jpg_image = imagecreatefromjpeg('02.JPG');
$orig_width = imagesx($jpg_image);
$orig_height = imagesy($jpg_image);
// Allocate A Color For The background
$bcolor=imagecolorallocate($jpg_image, 255, 255, 255);
//Create background
imagefilledrectangle($jpg_image, 0, $orig_height*0.9, $orig_width, $orig_height, $bcolor);
// Set Path to Font File
$font_path = realpath(dirname(__FILE__)).'/arial.ttf';
// Set Text to Be Printed On Image
$text = "New Content Goes to here";
// Allocate A Color For The Text
$color = imagecolorallocate($jpg_image, 0, 0, 0);
// Print Text On Image
imagettftext($jpg_image, 20, 0, 10, $orig_height-10, $color, $font_path, $text);
//Set the Content Type
header('Content-type: image/jpg');
// Send Image to Browser
imagejpeg($jpg_image);
// Clear Memory
imagedestroy($jpg_image);
Image: