Jump to content


Photo

write text in image


  • Please log in to reply
6 replies to this topic

#1 neugi

neugi
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts

Posted 02 July 2006 - 09:09 AM

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.

    
    $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);

myabe someone can find the problem.

thx

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 02 July 2006 - 09:25 AM

is the font file "rabiohead.ttf" in same folder as script?

Comment out the header() and run script to show error messages
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 neugi

neugi
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts

Posted 02 July 2006 - 09:28 AM

is in the same direktory ;)

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

best

#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 02 July 2006 - 09:29 AM

try moving the text (baseline) coords further down the image so text is inside the image
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 02 July 2006 - 10:18 AM

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);

//?>
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#6 neugi

neugi
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts

Posted 02 July 2006 - 10:45 AM

thx worked

#7 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 02 July 2006 - 10:50 AM

I have spent ages on your code but sorry can not get the gof to work like the png sorry.

all the best.


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users