Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

//Load font
if(!($myFont = imagepsloadfont($font_file)))
{
print("Unable to load font!");
exit();
}


//set encoding
imagepsencodefont("IsoLatin1.enc");


//get bounding box
$Box = imagepsbbox($text, $myFont, $size, $spacing, $letting,
$angle);


//create an image with ten extra pixels
$image = imagecreate($Box[1]+10, $Box[3]+10);
$colorRed = imagecolorallocate($image, 0, 0, 0);
$colorBlack = imagecolorallocate($image, 0, 0, 0);
imagefill($image, 10, 10, $colorRed);


//write the text
imagepstext($image, $text, $myFont, $size,
$colorBlack, $colorRed,
0, 0, $spacing, $letting,
$angle, $antialias_steps);


//unload font
imagepsfreefont($myFont);


//send image
header("Content-type: image/jpeg");
imagejpeg($image);
?>


imagerectangle(integer image, integer top_left_x, integer
top_left_y, integer bottom_right_x, integer bottom_right_y,
integer color)


The imagerectangle function draws a rectangle based on the top-left and bottom-right
corners. The inside of the rectangle will not be filled as it is with the
imagefilledrectangle function.


<?
/*
* Draw a hollow black rectangle
/


//create yellow square
$image = imagecreate(200,200);
$colorYellow = imagecolorallocate($image, 255, 255, 0);
$colorBlack = imagecolorallocate($image, 0, 0, 0);
imagefill($image, 0, 0, $colorYellow);

Free download pdf