PHP imagefttext (imagettftext) doesn't display anything

I am pretty sure that there is a stupid reason why this does not work, but I just can't figure it out. I'm just trying to print some text as a graphic with imagettftext, but I can't get the words to display. This is on the GoDaddy server, so I do not control everything, but here are the specifications from phpinfo ():

  • PHP Version 5.2.14
  • - with-gd '' --with-freetype-dir = / usr '' --with-jpeg-dir = / usr '' --with-png-dir = / usr / bin / libpng-config '' - enable-gd-native-ttf '
  • GD support
  • GD version included (compatible with 2.0.34)
  • FreeType Support Included
  • FreeType Communication with freetype
  • FreeType Version 2.2.1

Here is the code I'm using. Nothing unusual or strange.

$width = 270;
$height = 25;
$image = imageCreate($width, $height);
$white = imageColorAllocate($image, 255, 255, 255);
$black = imageColorAllocate($image, 0, 0, 0);
$font = 'verdana.ttf';
imagefttext($image, 16, 0, 0, 0, $black, $font, 'TESTING TEXT');
header("Content-type:  image/gif");
imageGIF($image);

I tried changing the font name in many ways:

$font = './verdana.ttf';
$font = dirname(__FILE__).'/verdana.ttf';

PNG GIF, imagefttext() imagettftext(), , , . ? - ...

+5
3

( , , ...)

, Y- offeset , :

<?php
$width = 270;
$height = 25;
$image = imageCreate($width, $height);
$white = imageColorAllocate($image, 255, 255, 255);
$black = imageColorAllocate($image, 0, 0, 0);
$font = 'verdana.ttf';
imagettftext($image, 16, 0, 0, 16, $black, $font, 'TESTING TEXT');
header("Content-type:  image/gif");
imageGIF($image);
?>
+6

, imagettftext ?

+1
$font = "verdana.ttf";
$im = @imagecreatetruecolor(270, 25)
      or die('Cannot Initialize new GD image stream');
$backg = imagecolorallocate($im,255,255,255);
imagefill($im, 0, 0, $backg);
$color = ImageColorAllocate($im, 0,0,0);
ImageTTFText($im,16,0,0,16, $color,$font,'hello');
header ('Content-type: image/gif');
ImageGIF($im);
ImageDestroy($im);   

try this ... font in the same folder

+1
source

All Articles