01 <?php
02
03 function imagettftexttexture (& $im ,& $textureim ,$size ,$angle ,$x ,$y ,$fontfile ,$text )
04 {
05 // Get the width of the image
06 $width = imagesx($im);
07 // Get the height of the image
08 $height = imagesy($im);
09 // Create the buffer image
10 $buffer = imagecreate($width,$height);
11 // Get the width of the texture image
12 $tile_w = imagesx($textureim);
13 // Get the height of the texture image
14 $tile_h = imagesy($textureim);
15 // Find out how many times it fits horizontally
16 $fits_x = (int)($im_w/$tile_w);
17 // Find out how many times it fits vertically
18 $fits_y = (int)($im_h/$tile_h);
19 // Loop through every time (and another, for extra space) it fits horizontally
20 for($i =0; $i <= $fits_x; $i++)
21 {
22 // Change the X location based on where in the loop it is
23 $x = (int)($tile_w*$i);
24 // Loop through every time it fits vertically
25 for($i2 = 0; $i2 <= $fits_y; $i2++)
26 {
27 // Change the Y location
28 $y = (int)($tile_h*$i2);
29 // Copy the image to the X,Y location
30 $copy = imagecopy($im,$textureim,$x,$y,0,0,$tile_w,$tile_h);
31 }
32 }
33 // Create magic pink, a color commonly used for masks
34 $pink = imagecolorclosest($im,255,0,255);
35 // Make magic pink the transparent color
36 $trans = imagecolortransparent($im,$pink);
37 // Draw text over magic pink without aliasing
38 imagettftext($im,$size,$angle,$x,$y,-$pink,$fontfile,$text);
39 // Copy the main image onto the buffer
40 imagecopy($buffer,$im,0,0,0,0,$width,$height);
41 // Copy the buffer back onto the main image
42 imagecopy($im,$buffer,0,0,0,0,$width,$height);
43 // Destroy the buffer
44 imagedestroy($buffer);
45 }
46
47 ?>