0

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);
?>:
2
Contributors
1
Reply
12
Views
2 Years
Discussion Span
Last Post by diafol
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.