Jump to content

[SOLVED] Help loading font and wrinting on image GD


elpaisa

Recommended Posts

Hi!

 

I'm creating a function that takes values from database and puts these on an image and saves it as a new one, for now as i don't have much experience in GD i am writing it as simple as possible, everithing works fine without loading a font but i need to use arial black to write on the image.

 

Here is the code: that works without loading the font:

 

 

function createimage()
{

Header("Content-Type: image/gif");


$font = 'ariblk.ttf';
$font_size = 2;
$string = 'ADDERALL';
$id = ImageCreateFromGif("images/pot.gif");
$black = ImageColorAllocate($id, 0, 0, 0);

//imagettftext($id, $font_size,  35, 76, $font, $string, $black);

ImageString($id, $font_size,  35, 76, $string, $black);
ImageGIF($id,"images/new_pot.gif");

}

createimage();

 

And here is the one i am trying with, for using the font:

 

 

function createimage()
{

Header("Content-Type: image/gif");


$font = 'ariblk.ttf';
$font_size = 2;
$string = 'ADDERALL';
$id = ImageCreateFromGif("images/pot.gif");
$black = ImageColorAllocate($id, 0, 0, 0);

imagettftext($id, $font_size,  35, 76, $font, $string, $black);

//ImageString($id, $font_size,  35, 76, $string, $black);
ImageGIF($id,"images/new_pot.gif");

}

createimage();

 

 

Link to comment
Share on other sites

Well, afther no response for a long time i tried all the possible coding and i've solved it

Thanks!!

 

function createimage()
{

Header("Content-Type: image/gif");

$id = ImageCreateFromGif("images/pot.gif");
$string = 'ADDERALL';
$black = ImageColorAllocate($id, "#000000");

ImageTTFText($id, 7, 0, 30, 88, $black, "AEASWFTE.TTF", $string);
ImageTTFText($id, 7, 0, 31, 88, $black, "AEASWFTE.TTF", $string);
ImageGIF($id,"images/new_pot.gif");

}

createimage();

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.