View Full Version : GD Image Cannot be Displayed

08-23-2009, 07:39 AM
Can someone please help me pinpoint why this image is not being shown?


Here is the source code. I have compared it to quite a few GD scripts, and don't see anything wrong with my code. I am actually a bit confused. Might be because I'm picking up PHP after two years of not doing much. :thumbsup:

All I get is

The image “http://jordan.rave5.com/tvshack/latest_movies.png/” cannot be displayed, because it contains errors.

It isn't a problem with the XML parsing, that is all groovy. Something with the GD rendering.

[ Code Removed ]

08-23-2009, 08:00 AM
If you examine the contents that your code is producing, you will find the following error -

<br />
<b>Fatal error</b>: Call to undefined function imagettftext() in <b>/home/amerikan/public_html/tvshack/latest_movies.png/index.php</b> on line <b>32</b><br />

I'll guess that you don't have the the FreeType library since the other GD functions are not producing any errors.

08-23-2009, 08:09 AM
Hehe, thank you.

08-23-2009, 08:37 AM
I am now getting the same error with this code, however imagestring() does exist.

And forgive me, my server is not generating an error file. Or showing me the errors via the problem at http://jordan.rave5.com/tvshack/latest_movies.png


error_reporting( E_ALL & ~E_NOTICE );

header ( 'Content-type: image/png' );

$font = imageloadfont( './Duepuntozero.tff' );

$source = './tvs_new_movies_background.png';

$image = imagecreatefrompng( $source );
imagealphablending( $image, false );
imagesavealpha( $image, true );

$blue = imagecolorallocate( $image, 16, 76, 104 );
$green = imagecolorallocate( $image, 116, 160, 80 );

$tvs_feed = 'http://tvshack.net/rss/movies.xml';

$dom = new DOMDocument();
$dom->load( $tvs_feed );

$items = $dom->getElementsByTagName( 'item' );
$movies = array();

foreach ( $items as $item ) {

$title_tag = $item->getElementsByTagName( "title" );
$movies[] = $title_tag->item(0)->nodeValue;


// Row One
imagestring( $image, $font, 120, 30, html_entity_decode( $movies[0] ), $green );
imagestring( $image, $font, 120, 45, html_entity_decode( $movies[0] ), $blue );
imagestring( $image, $font, 120, 60, html_entity_decode( $movies[0] ), $green );
imagestring( $image, $font, 120, 75, html_entity_decode( $movies[0] ), $blue );

// Row Two
imagestring( $image, $font, 250, 30, html_entity_decode( $movies[0] ), $blue );
imagestring( $image, $font, 250, 45, html_entity_decode( $movies[0] ), $green );
imagestring( $image, $font, 250, 60, html_entity_decode( $movies[0] ), $blue );
imagestring( $image, $font, 250, 75, html_entity_decode( $movies[0] ), $green );

imagepng( $image );
imagedestroy( $image );


08-23-2009, 08:46 AM
The current error is not the same. It concerns the file or directory of the .tff file in -

$font = imageloadfont( './Duepuntozero.tff' );

08-23-2009, 09:06 AM
How can this be? THe file is there. I tried three other linking methods. Man. It is weird. No error reporting at all on the server. Can't even upload a .htaccess file to force errors to a log file. :(

08-23-2009, 09:11 AM
To see the errors, comment out the header() statement or save the output from the link you have been posting to a file and open that file in a good programming editor.

08-23-2009, 09:13 AM
... Lol Wow, it really has been awhile since I've used PHP.