Toon posts:

[php] ImageTTFText , can't find/open font.

Pagina: 1
Acties:

Verwijderd

Topicstarter
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?
// header("Content-type: image/jpeg");
//
// get src image and dimensions
$src_img = ImageCreateFromJPEG("test.jpg");
$src_w = ImageSX($src_img);
$src_h = ImageSY($src_img);
//
// create empty true color canvas, def bg is black
$txt_img = ImageCreateTrueColor($src_w,$src_h);
//
// define colors
$white = ImageColorAllocate ($txt_img, 255, 255, 255);
$black = ImageColorAllocate ($txt_img, 0, 0, 0);
//
// add your white text
imagettftext ($txt_img, 80, 25, 65, 350, $white, "./picstore2/times.ttf", "Testing...Omega: &#937;");
// ImageTTFText ($txt_img, 80, 25, 65, 350, $white, "times.ttf", "Kung Fu") or die("hallo");
//
// make black bg transparent
ImageColorTransparent($txt_img, $black);
//
// merge text image onto src image
ImageCopyMerge($src_img,$txt_img,0,0,0,0,$src_w,$src_h,30); // 30% opacity

//
// create empty true color canvas for resizing.
$dst_img = ImageCreateTrueColor(100,100);
//
// resize
ImageCopyResampled($dst_img,$src_img,0,0,0,0,100,100,$src_w,$src_h);
//
// output to browser.
ImageJPEG($dst_img,'',70); // quality 70

?>


ik krijg dus de melding dat het font niet geopend of gevonden kan worden?... is er een manier om toch een text op een plaatje te krijgen? met gd/php?

  • Pelle
  • Registratie: Januari 2001
  • Laatst online: 17:45

Pelle

🚴‍♂️

Gebruik realpath("./picstore2/times.ttf")
Is niet goed gedocumenteerd op php.net, moet wel.

Verwijderd

Topicstarter
ik begrijp je niet, realpath? :D

PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Header("Content-type: image/pjpeg");  

$im = ImageCreateFromJPEG("flesje.jpg");  

$white = imagecolorclosest($im,255,255,255); 

$text = "http://galleries.vinyamar.com/ps" ;

$iwidth = imagesx($im) - (6 * strlen($text));
$iheight = imagesy($im) - 12;

//right
// imagestring($im, 2, $iwidth, $iheight, $text, $white); 

// left
// imagestring($im, 2, 1, $iheight, $text, $white); 

// center
imagestring($im, 2, ($iwidth / 2), $iheight, $text, $white); 
Imagejpeg($im); 
ImageDestroy ($im);
?> 


dit heb ik net ff in elkaar geknutseld met wat stuff dat ik hier vond, best geinig :D

Verwijderd

Topicstarter
Pelle schreef op 21 augustus 2002 @ 22:50:
Gebruik realpath("./picstore2/times.ttf")
Is niet goed gedocumenteerd op php.net, moet wel.
werkt echter niet :{

PHP:
1
2
3
$font = realpath("./picstore2/times.ttf");
imagettftext ($txt_img, 80, 25, 65, 350, $white, $font, "Testing...Omega: &#937;"); 
// ImageTTFText ($txt_img, 80, 25, 65, 350, $white, realpath("times.ttf"), "Kung Fu") or die("hallo");

  • Pelle
  • Registratie: Januari 2001
  • Laatst online: 17:45

Pelle

🚴‍♂️

Bij mij deed dit 'm.

PHP:
1
imageTTFText($text_img, 80, 25, 65, 350, $white, realpath("./picstore2/times.ttf"), "Kung Fu");


Heeft je PHP wel TTF ondersteuning? Misschien wel handig om dat ook ff te checken.

  • HurrI
  • Registratie: Maart 2001
  • Laatst online: 06-05 23:45

HurrI

No fear... I is here

welke php versie draai je? en welke gd lib?

If it's just us, it seems like an awful waste of space


  • Willem2
  • Registratie: Oktober 2000
  • Laatst online: 19:11

Willem2

Ω is futile

realpath; oftwel absoluut pad. ZO werkt ie bij mij (linux/GD2):

PHP:
1
$font ="/usr/local/apache/htdocs/arial.ttf";

en nee, ik houd niet van voetbal... :)


Verwijderd

Topicstarter
HurrI schreef op 21 augustus 2002 @ 23:33:
welke php versie draai je? en welke gd lib?
PHP Version 4.2.1

GD Support enabled
GD Version 2.0 or higher
FreeType Support enabled
FreeType Linkage with freetype
JPG Support enabled
PNG Support enabled
WBMP Support enabled

  • nrg
  • Registratie: April 2001
  • Laatst online: 19-05 20:52

nrg

Hoe zit het met de rechten van de fontfile?

Verwijderd

Topicstarter
welke rechten? winhooz systeem...

  • Ericston
  • Registratie: Maart 2001
  • Laatst online: 30-03 17:41
Je weet dat "./picstore2/times.ttf" gelijk staat aan "picstore2/times.ttf" mag ik hopen. :)

Verwijderd

Topicstarter
Ericston schreef op 25 augustus 2002 @ 00:50:
Je weet dat "./picstore2/times.ttf" gelijk staat aan "picstore2/times.ttf" mag ik hopen. :)
tuurlijk :)

Verwijderd

Nu zit ik weer met hetzelfde probleem; echter kan ik het antwoord dat mij toen heeft geholpen niet meer terug vinden, het was iets van de path naar de 'fonts' in de variables van GD zetten ofzo, iemand een idee?
Pagina: 1