Questions tagged [imagettftext]

174 questions
6
votes
2 answers

Using PHP GD to create image form text with different fonts

I have been using this simple script to generate images from text:
Meredith
  • 920
  • 6
  • 16
  • 29
6
votes
3 answers

PHP imagefttext (imagettftext) not displaying anything

I'm almost positive that there is a stupid reason this is not working, but I just can't figure this one out. I'm just trying to print out some text as a graphic with imagettftext, but I can't get the words to display. This is on a GoDaddy server,…
SenorPuerco
  • 839
  • 2
  • 8
  • 18
6
votes
4 answers

How do I deal with characters unsupported by the font file when using imagettftext()?

I use Verdana font inside my images created by PHP GD library. imagettftext($image, $fontSize, 0, 70, $y, $color, $font, $username ); Most of the cases imagettftext works very well for strings. But some of my users use weird characters/symbols…
trante
  • 30,976
  • 45
  • 174
  • 260
5
votes
5 answers

PHP function imagettftext() to write text with smileys

I am using imagettftext function to write text on image but my text contain smileys and it replace smileys to square box Here is mycode: $black = imagecolorallocate ( $main_img, 0x00, 0x00, 0x00 ); $font_path = "Arial.ttf"; imagettftext ( $main_img,…
Bhumi Shah
  • 8,514
  • 5
  • 54
  • 88
5
votes
2 answers

PHP's imagettftext creates black edges on transparent background

I have this code: $im = imagecreatetruecolor(70, 25); $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 128, 128, 128); $black = imagecolorallocate($im, 0, 0, 0); imagecolortransparent($im, imagecolorallocate($im,…
Sp3ct3R
  • 685
  • 1
  • 12
  • 24
5
votes
4 answers

PHP imagettftext partially bold

I'm training my PHP skills to generate images. I need only one thing which doesn't work. I don't think it's possible on the way I want, but there should be another way. The code I already have is this:
Wietse de Vries
  • 685
  • 1
  • 5
  • 18
4
votes
4 answers

Invalid font filename (imagettfbox)

This question has been asked over and over but I could not find the correct answer to my problem... As a little background note, all the code was working perfectly before we moved the class file from /application/lib/class to /library/class ... I…
Salketer
  • 11,628
  • 2
  • 23
  • 56
4
votes
2 answers

How to write text in multiline(in a paragraph)?

When i use this code,I can make a image out of text,but in a single line, function writetext($image_path,$imgdestpath,$x,$y,$angle,$text,$font,$fontsize) { $image=imagecreatefromjpeg("$image_path"); $height = imageSY($image); …
pushE
  • 374
  • 3
  • 14
4
votes
2 answers

imagettftext(): calculate font size to ensure text fits image width

I'm using imagettftext() to write dynamic text on an image and I want it to fit my image width. How can I calculate the font size by the text lenght?
Asaf
  • 91
  • 1
  • 1
  • 8
3
votes
3 answers

PHP imagettftext always drawing black

Basically when I draw text it's ending up black like this: http://i.stack.imgur.com/z675F.png Instead of the color I'm allocated in PHP and the function. Code: $finalImage = imagecreatefrompng($imageFile); $logo =…
UberMouse
  • 845
  • 12
  • 23
3
votes
2 answers

Underline text using imagettftext

My question is, how do I underline all the text in the image?Code: function createImage($text) { $text .= "\n"; $text = wordwrap($text, 40, "\n"); $newlines = substr_count($text, "\n"); if($newlines == 0) { $height = 30; …
William N
  • 422
  • 4
  • 12
3
votes
3 answers

How to control text alignment for text generated using `imagettftext()`?

Using the imagettftext function from the PHP GD library, one can only draw text that is left-aligned onto an image. At least so it would seem, perhaps I'm missing something. How can I control the alignment of the text drawn onto an image? i.e. left…
Andrei Oniga
  • 7,288
  • 12
  • 47
  • 80
3
votes
0 answers

How to make text-align center in imagettftext()

I couldn't able to get this working. See the picture below (this is im showing in a div tag): html code is

t-shirt is the giveaway

How can i achieve the same thing displayed in the image using imagettftext()
agurchand
  • 1,465
  • 2
  • 14
  • 23
2
votes
1 answer

Add text from user input to an image [imagettftext]

Trying to find a way of doing this, but going round in circles. What we are trying to achieve is like this I have read up on : http://php.net/manual/en/function.imagettftext.php and http://us2.php.net/manual/en/function.imagejpeg.php I am just going…
422
  • 5,578
  • 21
  • 77
  • 133
2
votes
0 answers

Multiple text colors in one image using imagettftext

I am trying to output some text using imagettftext. I can do this easily enough to get text that is all one color. What I would like to do is have individual words be different colors. Is this possible using this function? My other thought was to…
Terry Waltz
  • 121
  • 2
1
2
3
11 12