I'm running PHP 4.2.3 on a RH 7.2 box. I just compiled 4.2.3 yesterday with GD support, relevant library versions are:
gd: 2.0.1
freetype: 2.1.2
libpng: 1.2.4
zlip: 1.1.4
I'm trying to use the TTF functions to draw text on an image I'm creating on the fly (using ImageCreateTrueColor). Problem is, the fonts are not anti-aliased. From what I've found doing searches, they SHOULD be, however. Here's some of my code:
1 <?php
2
3 // Figure out what image type the source is
4 $arr_img_name = split("\.", $_GET['image_source']);
5
6 if($arr_img_name[1] == "gif")
7 {
8 $obj_image_orig = ImageCreateFromGif($_GET['image_source'])
9 or die("Could not open source image!");
10 }
11 elseif($arr_img_name[1] == "jpg")
12 {
13 $obj_image_orig = ImageCreateFromJpeg($_GET['image_source'])
14 or die("Could not open source image!");
15 }
16 else
17 {
18 print "Could not open source image!";
19 exit;
20 }
21 $arr_image_attrib = GetImageSize($_GET['image_source']);
22
23 // Open the logo image to superimpose
24 $obj_image_logo = ImageCreateFromPng("evs_logo.png");
25
26 // Create the thumbnail image
27 $obj_image_thumb = ImageCreateTrueColor(($arr_image_attrib[0] / 2), ($arr_image_attrib[1] / 2))
28 or die("Could not create thumbnail image!");
29 $rsrc_clr_white = ImageColorAllocate($obj_image_thumb, 255, 255, 255);
30 ImageAlphaBlending($obj_image_thumb, TRUE);
31
32 // Resize the image
33 ImageCopyResampled($obj_image_thumb, $obj_image_orig, 0, 0, 0, 0,
34 ($arr_image_attrib[0] / 2), ($arr_image_attrib[1] / 2), $arr_image_attrib[0], $arr_image_attrib[1]);
35
36 // Superimpose the logo onto the thumbnail
37 ImageCopy($obj_image_thumb, $obj_image_logo, (($arr_image_attrib[0] / 4) - 75), (($arr_image_attrib[1] / 4) - 22),
38 0, 0, 150, 45);
39
40 // Add some text
41 $rsrc_clr_black = ImageColorAllocate($obj_image_thumb, 0, 0, 0);
42 ImageTTFText($obj_image_thumb, 12, 0, 25, 25, $rsrc_clr_black, "/usr/local/ttfonts/arial_normal.ttf", "This is a test . . .");
43
44 // Send the header and image information
45 header("Content-type: image/jpeg");
46 ImageJpeg($obj_image_thumb,'' , 100);
47
48 // Destroy the image objects
49 ImageDestroy($obj_image_thumb);
50 ImageDestroy($obj_image_orig);
51 ImageDestroy($obj_image_logo);
52
53 ?>
Anybody see anything I'm missing?