Member Avatar for James singizi

i am trying to draw an image on to a php page using the imagecreate function but the image is not showing, i cant see the problem with this code, please help me out, the code is as follows:

<?php

header('content-type: image/jpeg');
$fontSize = 30;

$imageHeight = 40;
$imageWidth = 200;

$image = imagecreate($imageWidth,$imageHeight);

imagecolorallocate($image,10,120,0);
$textColor = imagecolorallocate($image, 0, 0, 0);
imagettftext($image, 20, 0, 15, 30, $textColor, 'font.ttf', 'james');
imagejpeg($image);
?>:
Member Avatar for diafol

It may be caused by having whitespace before the <?php tag

<?php
header('content-type: image/jpeg');
$fontSize = 30;
$imageHeight = 40;
$imageWidth = 200;
$image = imagecreate($imageWidth,$imageHeight);
imagecolorallocate($image,10,120,0);
//$textColor = imagecolorallocate($image, 0, 0, 0);
//imagettftext($image, 20, 0, 15, 30, $textColor, 'font.ttf', 'james');
imagejpeg($image)
?>

I don't have your font, so I commented out a few lines. The above displayed for me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.