-2

i have developed this code for image but the problem is that my text is not appearing on this image please help ! code is running fine with no error. Displaying the white image as mentioned in this code.

<?php
//Set the Content Type
header('Content-type: image/jpg');

$w=730;
$h=450;

$image=imagecreate($w,$h);
$text='hello world';

$whitebackground=imagecolorallocate($image,255,255,255);

$blacktext=imagecolorallocate($image,0,0,0);
$font =$font_path = dirname(__FILE__) . '/themify.ttf';

imagettftext($image,40,0,50,50,$blacktext,$font,$text);
imagejpeg($image);

ini_set("log_errors", 1); ini_set("error_log", "php-error.log");
?>
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Dev vivek
  • 45
  • 1
  • 8

1 Answers1

0

I've run the following code and it is working fine. Only change is font type, I've used the arial.ttf font. I've attached the output file.

<?php
//Set the Content Type
header('Content-type: image/jpg');

$w=730;
$h=450;

$image=imagecreate($w,$h);
$text='hello world';

$whitebackground=imagecolorallocate($image,255,255,255);

$blacktext=imagecolorallocate($image,0,0,0);
$font =$font_path = dirname(__FILE__) . '/arial.ttf';

imagettftext($image,40,0,50,50,$blacktext,$font,$text);
imagejpeg($image);
?>

enter image description here

johirpro
  • 509
  • 4
  • 16
  • Thank you so much i haven't tried yet but i think it will be running fine. So. why it is not working that given font? – Dev vivek Jan 10 '19 at 15:32