Possible GD issue, possible me being an idiot issue

Status
Not open for further replies.

ViperBlade

New Member
Messages
186
Reaction score
0
Points
0
I have apache installed on my PC and the code I'm about to provide works fine. It's supposed to be a grey background with white text.
For some reason it doesn't work when I upload it to my account's space. It gives the grey background but no text.

PHP:
<?
// Some basic setup
$imageWidth = 300;
$imageHeight = 32;
$textFont = "arialbd.ttf";
$textSize = 15;

error_reporting(0);

$server = "http://viperblade.no-ip.org";
$port = "80";
$timeout = "0.1";

$TScheck = fsockopen($server, $port, $errno, $errstr, $timeout);

if ($TScheck)
    {
    $textString = "ViperBlade's PC is on!";
    }
else
    {
    $textString = "Nobody's home right now";
    }

// Set the headers content type
header("Content-type: image/png");

// Create the image
$image = imagecreatetruecolor($imageWidth, $imageHeight);

// Create some colors
$white = imagecolorallocate($image, 255, 255, 255);
$black = imagecolorallocate($image, 44, 144, 44);

// Fill the background of our image
imagefilledrectangle($image, 0, 0, $imageWidth, $imageHeight, $black);

// Get box info
$box = imagettfbbox($textSize, 0, $textFont, $textString);

//Find out the width and height of the text box
$textW = $box[2] - $box[0];
$textH = $box[5] - $box[3];

// Calculate the positions
$positionLeft = ($imageWidth - $textW)/2;
$positionTop = (($imageHeight - $textH)/2)-2;

// Add some text
imagettftext($image, $textSize, 0, $positionLeft, $positionTop, $white, $textFont, $textString);

// Output the image to the browser
imagepng($image);

// Destroy the image
imagedestroy($image); 
?>
 

DefecTalisman

Community Advocate
Community Support
Messages
4,148
Reaction score
5
Points
38
Have you tried changing the position to one that is known ?
PHP:
imagettftext($image, $textSize, 0, $positionLeft, $positionTop, $white, $textFont, $textString);
to
PHP:
imagettftext($image, $textSize, 0, 10, 10, $white, $textFont, $textString);
 

ViperBlade

New Member
Messages
186
Reaction score
0
Points
0
Have you tried changing the position to one that is known ?
PHP:
imagettftext($image, $textSize, 0, $positionLeft, $positionTop, $white, $textFont, $textString);
to
PHP:
imagettftext($image, $textSize, 0, 10, 10, $white, $textFont, $textString);

I already tried that. Nothing.
 

Corey

I Break Things
Staff member
Messages
34,551
Reaction score
204
Points
63
I have verified GD is installed on your server...

Can you check the error log in cPanel and see if it's outputting any errors in the background?

-Corey
 

ViperBlade

New Member
Messages
186
Reaction score
0
Points
0
Nope. Only the one error message, and that's one I already knew about.
Edit:
I was correct before. Possible me being an idiot issue.
I forgot to upload the font file.

*Hides away in embarrassment*

Closed
 
Last edited:
Status
Not open for further replies.
Top