Questions tagged [imagettftext]

174 questions
7
votes
1 answer

PHP GD Text with Transparency/Alpha background

alright so im having a problem with getting my text layed over a partly transparent image. i want the text to be solid, but i want part of the background of the image to be transparent, and the part the text is over to be solid, which i have, the…
user258640
  • 251
  • 1
  • 2
  • 5
6
votes
2 answers

Open OTF fonts with php - greek characters included

So, as the title says, my task is to convert a given phrase to an image on server side (php GD) with a selected .otf font. The phrase can include not only latin characters but also greek and cyrillic. PHP's imagettftext…
magtak
  • 986
  • 1
  • 9
  • 20
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
  • 7
  • 16
  • 31
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
  • 33,518
  • 47
  • 192
  • 272
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
  • 715
  • 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
  • 695
  • 1
  • 5
  • 18
4
votes
3 answers

PHP imagettftext always drawing black

Basically when I draw text it's ending up black like this: https://i.stack.imgur.com/z675F.png Instead of the color I'm allocated in PHP and the function. Code: $finalImage = imagecreatefrompng($imageFile); $logo =…
UberMouse
  • 917
  • 2
  • 12
  • 26
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
  • 14,263
  • 2
  • 30
  • 58
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
  • 394
  • 3
  • 16
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
1 answer

PHP imageftbbox imagettftext - simple letter spacing/kerning?

Does anyone know a simple way to do letter spacing/kerning using imagettftext? I have my script working just as I need now, but I could really do with the generated text having the CSS style letter-spacing: -0.01em; so it matches the standard text…
Danny Shepherd
  • 363
  • 1
  • 3
  • 17
3
votes
1 answer

imagettftext and arabic language: how can I write in RTL mode?

I need to write in RTL mode to imagettftext, 'caus arabic language is in this way: and I don't mean to revert the letters, I mean a css-like RTL (direction:rtl), so aligned-flag on the right... how can I? My easy…
Zak
  • 591
  • 2
  • 15
  • 37
3
votes
1 answer

PHP imagettftext() center text

I want to center the text I add to my image using : imagettftext($image, 85, 0, 250, 350, $color, $font, $txt ); I tried something like this : $fontwidth1 = imagefontwidth($font); $center1 = (imagesx($image)/2) -…
BRDS
  • 89
  • 1
  • 1
  • 5
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
  • 432
  • 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
  • 8,219
  • 15
  • 52
  • 89
1
2
3
11 12