Jump to content

Archived

This topic is now archived and is closed to further replies.

neugi

write text in image

Recommended Posts

Hi,

i want to use this code to write a text to a img, but it din't work and i don't know why.

[code]   
    $font = "rabiohead.ttf";
    $grund_bild = "barcode.gif";
    $winkel = "90";
    $text = "test";

    $img = imagecreatefromgif($grund_bild);
    $black = imagecolorallocate($img, 0,0,0);
    imagettftext($img, 10, $winkel, 0, 0, $black, $font, $text);

    header("Content-type: image/gif");
    imagegif($img);
    imagedestroy($img);[/code]

myabe someone can find the problem.

thx

Share this post


Link to post
Share on other sites
is the font file "rabiohead.ttf" in same folder as script?

Comment out the header() and run script to show error messages

Share this post


Link to post
Share on other sites
is in the same direktory ;)

and if the header is away there is no error message, i've checked this already.

best

Share this post


Link to post
Share on other sites
try moving the text (baseline) coords further down the image so text is inside the image

Share this post


Link to post
Share on other sites
this is a png version ok and tested

//<?php

//header("Content-type: images/png");
//$string = "hi";
//$im    = imagecreatefrompng("images/banner.png");
//$orange = imagecolorallocate($im, 220, 210, 60);
//$px    = (imagesx($im) - 7.5 * strlen($string)) / 2;
//imagestring($im, 3, $px, 9, $string, $orange);
//imagepng($im);
//imagedestroy($im);

//?>

Share this post


Link to post
Share on other sites
I have spent ages on your code but sorry can not get the gof to work like the png sorry.

all the best.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.