/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] image help

how can i add some text to the top of the image (white)

the font file is there (base 02), Text isn’t appearing

[code=php]
<?php
function LoadGif ($imgname)
{
$im = @imagecreatefromgif ($imgname);
if (!$im) {

$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
$text = ‘Testing…’;
$font = ‘font.ttf’;

imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);
imagettftext($im, 20, 0, 10, 20, $white, $font, $text);

imagestring ($im, 1, 5, 5, “Error loading $imgname”, $tc);

}
return $im;
}
header(“Content-Type: image/gif”);
$img = LoadGif(“header.gif”);
imagegif($img);
?>
[/code]

Thanks in advanced =)

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@TheBearMayMay 20.2008 — The main problem is your "if" statement:
[code=php]
<?php

function LoadGif ($imgname)
{
$im = @imagecreatefromgif ($imgname);
if ($im) {

$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
$text = 'Testing...';
$font = "font.ttf";
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);
imagettftext($im, 20, 0, 10, 20, $white, $font, $text);
}
return $im;
}
header("Content-Type: image/gif");
$img = LoadGif("header.gif");
imagegif($img);

?> [/code]
Copy linkTweet thisAlerts:
@bradmasterxauthorMay 20.2008 — thanks i actually got that bit from php.net lol thanks
×

Success!

Help @bradmasterx spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...