/    Sign up×
Community /Pin to ProfileBookmark

Problems with imagettftext. help!?

After my webhotel updated there php version, i have experienced some problems getting text onto image, using the imagettftext()…

I tried to look up for some answer, but found nearly nothing.. but there was one thing i found, at php.net… That i think are the answer on my issue. But nevertheless, I still can’t get it to work..

Here is the comment from php.net:

[QUOTE]

I’ve recently had a problem with a image script that overlays text on top of a truecolour image, using the imagettftext function. The problem is the any text on the image just simply refuses to appear, regardless of specifying the full path of the font file or not.

The script used to work fine, until version 4.3.0, and the same problem seems to exist in version 4.3.1 and 4.3.2

For those who are stuck with this problem, here is my work around.

You need to create a 2nd overlay image which is the same size as the using the imagecreate function. Then you set the background colour to a transparent colour.

Once this is done, use the imagettftext functions to draw the text onto the overlay image.

When you have completed drawing onto the overlay image, the image needs to be overlayed onto the truecolour image. Just use the imagecopymerge function with a PCT value of 100.

Then continue to use the imageJPEG and imagePNG functions as normal, hopefully with your text on it!

[/QUOTE]

Here are some codes that i have been working on, that doesnt work..

[code=php]
$img = ImageCreateFromJpeg($pfile);

$img2 = imagecreate(200,200);

$black = imagecolorallocate ($img2, 0, 0, 0);
$white = imagecolorallocate ($img2, 255, 255, 255);

imagecolortransparent($img2,$black);

$font_file = “/hsphere/local/home/hamarlif/hamarliftutleie.no/temp/design/fonts/arial.ttf”;

imagettftext ($img2, 40, 0, 20,20, $white, $font_file , “HER KOMMER TEKST”);
imagecopymerge($img2,$img,0,0,0,0,$pic_width,$pic_height,100);

// Uploading picture to my domain
imageJPEG($img, “$bilde_large”);[/code]

Anyone know, why not any text comes onto the picture?? Anyone that might have some working codes on my issue??

Thanks ?

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @persa 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,
)...