I'm currently using imagecreatefromjpeg()
to add text to an image.
I have it working with all my files are in one folder, however I'm using CodeIgniter so my files are distributed throughout different folders.
What's the workaround to accomplish this?
I was thinking to put all my required files in my views, however that wasn't working.
See error
A PHP Error was encountered
Severity: Warning
Message: imagettftext(): Could not find/open font
Filename: views/coupon.php
Line Number: 30
See code
<?php
//Report any errors
ini_set("display_errors", "1");
error_reporting(E_ALL);
//Set the Content Type
// header('Content-type: image/jpeg');
// Create Image From Existing File
$jpg_image = imagecreatefromjpeg('http://localhost:8888/game/rcw/assets/couponWrite.jpg');
// Allocate A Color For The Text
$white = imagecolorallocate($jpg_image, 155, 155, 155);
// Set Path to Font File
$font_path = 'http://localhost:8888/game/rcw/application/views/Arial.ttf';
// Set Text to Be Printed On Image
$text = "IGL" . rand(55555,99999);
// Print Text On Image
imagettftext($jpg_image, 25, 0, 75, 300, $white, $font_path, $text);
// Send Image to Browser
imagejpeg($jpg_image);
// Clear Memory
imagedestroy($jpg_image);
?>