As I see it, you have two options;

1. Enlarge the image and place text in the image before outputing it.
2. place the text in the html page that has the image imbedded in it.

I have found it best to have each php program to output one thing at a time.
It may be possible to output both text and a image from the same file, but I
would not attempt to do it.  I would create two php programs, one to create
the html page, and a second to output the image.

1st I would create an html page that includes the image (while you can get
most browsers to display only an image, it will do very little else, unless
you first send the html page and tell the browser where in the page to place
the image.

<HTML><HEAD>.....
</HEAD><BODY>
...
<IMG SRC="program2.php"><br>
This is a square<br>
....
</BODY></HTML>

Then create the image in program2, the header tells the browser what format
the image is in.

<?php                   // not using php here may bite you some day
$new_w=50;
$new_h=50;

header("Content-type: image/png");
$src_img=ImageCreateFromPng("./square.png");    // this function will create
and load image
ImageCopyResized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),I
mageS($src_img));

// good, you may need to resize to allow room in the image for insertion of
text.

$black = ImageColorAllocate ($dst_img, 0, 0, 0);
ImageString($dst_img,$font,$x,$y,"This is a square", $black);

// the previous function will use some primative fonts OR

Imagettftext($dst_img, $font_size, $font_angle, $x, $y, $black,
"fontfilename", "This is a square");

// this second one will use truetype fonts

ImagePng($dst_img);             // finally output the image with text pixels set
?>

hope this helps,

Warren Vail
[EMAIL PROTECTED]


-----Original Message-----
From: Anthony Ritter [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 11, 2003 8:59 PM
To: [EMAIL PROTECTED]
Subject: [PHP-WIN] Outputing text with an image


How can I incorporate the text - "This is a square" - under the .jpg file?

The following php script outputs the reduced square but no copy.

Thank you.
Tony Ritter
..........................................................

<?
$new_w=50;
$new_h=50;

header("Content-type: image/png");
header("Content-type: text/html");
$dst_img=ImageCreate($new_w,$new_h);
$src_img=ImageCreateFromPng("./square.png");

ImageCopyResized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),I
mageSY($src_img));

ImagePng($dst_img);

echo "This is a square."; // This line does not print on output
?>



--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to