• 0

[PHP] GD help


Question

This is the code i have -

header("Content-type: image/png");
$string = "test";
$im     = imagecreatefrompng("images/test.png");
$orange = imagecolorallocate($im, 255, 255, 255);


$font = './images/ARIALBD.TTF';

imagettftext($im, 12, 0, 10, 36, $orange, $font, $string);


imagesavealpha($im, true);

imagepng($im);
imagedestroy($im);

I actually made the code work and it shows the text i want on the image i want but i have 2 problems:

1. When i see the picture and try to save it, the file name that it shows to save is the name of the PHP file i use .png and i would like to change the file name to something else and was not able to do so. I did try replace the imagepng($im); with imagepng($im, 'blabla.png'); and it didnt work.

2. How do i add effects to the text in here?

Thanks alot for the help.

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0
2. How do i add effects to the text in here?

Any specific effect in mind? If the effect includes complex shapes or anything like that, you need to draw them yourself.

The only things you can do with one line are the normal effects that the font comes with, if it comes, (italic, bold etc) and some basic stuff like antializing, text-width etc. If you need bevels, shadow, inset shadow etc, you need to stack multiple layers of text with gd.

After all, it's not like it's a graphics editor, it's a tool which you allows you to do one.

Link to comment
Share on other sites

  • 0

Would sending

header("Content-disposition: filename=blabla.png"); 

do the trick?

As for the latter question not sure.

Ye, that did the trick.. Thank you very much....

Any specific effect in mind? If the effect includes complex shapes or anything like that, you need to draw them yourself.

The only things you can do with one line are the normal effects that the font comes with, if it comes, (italic, bold etc) and some basic stuff like antializing, text-width etc. If you need bevels, shadow, inset shadow etc, you need to stack multiple layers of text with gd.

After all, it's not like it's a graphics editor, it's a tool which you allows you to do one.

I am actually talking about shadows and stuff like this...

Link to comment
Share on other sites

  • 0

I am actually talking about shadows and stuff like this...

Then you need to draw the same text twice (or multiple times if you want gradient shadow). Other one with black text to the bottom and the other to top with 1px offset.

You can find short example from PHP.net's imagettftext() manual.

Link to comment
Share on other sites

  • 0

Then you need to draw the same text twice (or multiple times if you want gradient shadow). Other one with black text to the bottom and the other to top with 1px offset.

You can find short example from PHP.net's imagettftext() manual.

Ye, i did that already and it looks o.k... I thought there is better way of doing it.

Do you know if there is a stroke effect option?

Link to comment
Share on other sites

  • 0

Here is another question:

How do i place an image on top of the image i already have?

The imagettftext is dealing with text, is there a command which deals with pictures aswell?

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.