I'm trying to render an image generated by a function call in php.
I've copy pasted a function found at php for kids and found elsewhere here.
function txt_to_png($textin){
//Set the Content Type
header('Content-type: image/jpeg');
// Create Image From Existing File
$jpg_image = imagecreatefromjpeg('../images/100.jpg');
// Allocate A Color For The Text
$white = imagecolorallocate($jpg_image, 255, 255, 255);
// Set Path to Font File
$font_path = '../fonts/lato-regular.ttf';;
// Set Text to Be Printed On Image
$text = "This is a sunset!"; // just hardcoding for moment
// 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);
}
I am calling the function as follows:
Print ('<img itemprop="image" src="');
txt_to_png($my_text_input);
Print ('">');
but it's not rendering the image correctly:
<img itemprop="image" src="�����JFIF���������>CREATOR: gd-jpeg v1.0 (using IJG JPEG v90), default quality
���C�
$.' " ,#(7),01444'9="82<.342���C" ="" ="" 2!!22222222222222222222222222222222222222222222222222����d�d"��������������="" �������}�!1aqa"q2���#b��r��$3br�="" %&'()*456789:cdefghijstuvwxyzcdefghijstuvwxyz�����������������������������������������������������������������������������������="" ������w�!1aqaq"2�b����="" #3r�br�="" $4�%�&'()*56789:cdefghijstuvwxyzcdefghijstuvwxyz���������������������������������������������������������������������������="" ��?��j(��="" (��="" (��?��"="">
Thanks for any help! Bill