php-windows Digest 12 Mar 2003 08:35:38 -0000 Issue 1630
Topics (messages 18978 through 18980):
Re: Newbie attempting file open...
18978 by: William Fisher
Outputing text with an image
18979 by: Anthony Ritter
18980 by: Warren Vail
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
Gentlemen,
I wanted to thank you as BOTH of your ideas worked (of course). I know that there
may be some questionable logic in my methods. But as I mentioned before, I am a
newbie. I'm much more at ease behind a drum set! Your expertise helped me out a lot so
thanks again.
"Svensson, B.A.T. (HKG)" <[EMAIL PROTECTED]> wrote:Hi Louis,
As you mihgt know, the "macro-function" I wrote is know as
"create-open".
I do understand your point about "why would I like to
read from an empty file?". Indeed this might seams strange,
but if one think twice about it, it might not be that bad
after all with a create open function.
Some higher level functions might assumes the existens of
a certain file, and if it does not excisit then these function
will fail (this fault is more commeon than one would belive is
true). For example a utility reading a log file might fail
if the log file is not present.
However a presence of an empty log file will be, from an
information point of view, as informative as a populated;
the empty file will namley tell (under normal condition)
that nothing special have happend. However a none existing
log file, might, casue program failures. And we don't want
that; especialy not in sattelite launch system, don't we?
However, I asked you to read it again, becuase your original
remark on my message was a tatotlogy in natural languages
on what I wrote in code form.
Kind regards,
//Anders
-----Original Message-----
From: Luis Moreira
To: Svensson, B.A.T. (HKG); ''William Fisher ' '
Cc: [EMAIL PROTECTED]
Sent: 2003-03-11 15:42
Subject: Re: [PHP-WIN] Newbie attempting file open...
What for ?
The option "r" stans for "read".
If what William is doing is try to read a file, and then create one if
it doesn't exist, to me that doesn't make sense (sorry).
If the function would do that it would always return an EMPTY file in
the second situation, right ?
Now I ask "why in God's name I want to read an empty file?"
What makes (more) sense is to open a file to write on, with the
possibility
to append if it exists or to create a new one if it doesn't.
What you suggest is "open, if it does not exist create".
You get a new (empty) file.
Then what ? Write ? That's what I wanted to say all along
Correct me if I am wrong
Luis
----- Original Message -----
From: "Svensson, B.A.T. (HKG)"
To: "'Luis Moreira '" ; "''William Fisher ' '"
Cc:
Sent: Tuesday, March 11, 2003 2:00 PM
Subject: RE: [PHP-WIN] Newbie attempting file open...
> Luis, read the code once again....
>
> -----Original Message-----
> From: Luis Moreira
> To: 'William Fisher '
> Cc: [EMAIL PROTECTED]
> Sent: 2003-03-11 12:03
> Subject: Re: [PHP-WIN] Newbie attempting file open...
>
> No need.
> It's the other way around, actually.
> The option that creates if the the file does not exist is "w". The "r"
> option only reads
>
> Luis
>
> ----- Original Message -----
> From: "Svensson, B.A.T. (HKG)"
> To: "'William Fisher '" ;
>
> Sent: Tuesday, March 11, 2003 9:15 AM
> Subject: RE: [PHP-WIN] Newbie attempting file open...
>
>
> > You may want to try something like this:
> >
> > $fp = @fopen(,"r");
> >
> > if ($fp)
> > {
> > print"An old file was opened!";
> >
> > } else {
> >
> > $fp = @fopen(,"w");
> > fclose($fp);
> > $fp = @fopen(,"r");
> > print"New file was created!";
> > }
> >
> > -----Original Message-----
> > From: William Fisher
> > To: [EMAIL PROTECTED]
> > Sent: 2003-03-10 19:54
> > Subject: [PHP-WIN] Newbie attempting file open...
> >
> >
> > The Question: It is my understanding that fopen() using the "r"
> option
> > will either open the indicated file for read only OR create one if
it
> > doesn't exist. fopen() is giving me this error when trying to
> > create/open a file.
> >
> > Warning: fopen(c:/program files/apache group/apache/htdocs/test.txt)
> > [function.fopen]: failed to create stream: No such file or directory
> in
> > c:\program files\apache group\apache\htdocs\file_open.php on line 5
> >
> > The Code: What I've written...well...copied... is this:
> >
> > > >
> > $DOCUMENT_ROOT = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];
> >
> > $fp = fopen("$DOCUMENT_ROOT/test.txt" , "r");
> >
> > ?>
> >
> >
> > The Guts: Windows ME, Apache 1.3.27, PHP 4.3.1.
> >
> > Why am I using ME? Call it compulsary. I buy the cheap gas, too. Any
> > ideas as to why this is happening? What's this whole file streaming
> > issue?
> >
> > Blessings,
> >
> > Zach Fisher....
> >
> >
> >
> > ---------------------------------
> > Do you Yahoo!?
> > Yahoo! Tax Center - forms, calculators, tips, and more
> >
> > --
> > 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
>
> --
> 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
---------------------------------
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online
--- End Message ---
--- Begin Message ---
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
?>
--- End Message ---
--- Begin Message ---
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
--- End Message ---