Re: [PHP] GD functions don't delete temporary files

2004-12-13 Thread Martin Holm
Steve wrote:
I am using GD image function with PHP (PHP 4.3.9 on RedHat 9). Today I 
found that for all images I have created so far (using the ImageGIF() 
function), there is a temporary file in /tmp with that image. The name 
of the temp file is a 6 character combination of letters and digits, 
e.g. jvc5Ne.

To be sure it's not a config problem, I compiled again with minumum 
options and minimum script

./configure --with-gd --with-zlib
?php
$im = ImageCreate(20, 20);
ImageGIF($im);
ImageDestroy($im);
?
But the problem is still there (CGI and CLI sapi tested). I used the 
-n option, so php.ini can't cause the problem, either.
Has anyone else experienced that?

Regards,
Steve
http://www.php.net/manual/en/function.imagegif.php -
*Note: * Since all GIF support was removed from the GD library in 
version 1.6, this function is not available if you are using that 
version of the GD library.

http://www.php.net/manual/en/function.imagecreatefromgif.php -
*Note: * GIF support was removed from the GD library in Version 1.6, and 
added back in Version 2.0.28. This function is not available between 
these versions.

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


Re: [PHP] GD functions don't delete temporary files

2004-12-13 Thread Steve
Jay Blanchard wrote:
[snip]
But the problem is still there (CGI and CLI sapi tested). I used the 
-n option, so php.ini can't cause the problem, either.
Has anyone else experienced that?
[/snip]

Yes. You will have to write your own clean-up code for things like this.
I don't mean any user generated temporary files, I mean files which are 
created by the PHP function ImageGIF(). How should I even know which 
temporary file name GD chose in each case, or whether it created a temp 
file at all in a particular case?

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


Re: [PHP] GD functions don't delete temporary files

2004-12-13 Thread Steve

http://www.php.net/manual/en/function.imagegif.php -
*Note: * Since all GIF support was removed from the GD library in 
version 1.6, this function is not available if you are using that 
version of the GD library.

http://www.php.net/manual/en/function.imagecreatefromgif.php -
*Note: * GIF support was removed from the GD library in Version 1.6, and 
added back in Version 2.0.28. This function is not available between 
these versions.
Well, that's not the problem.
As noted, I use PHP 4.3.9 which is bundled with GD 2.0.28, which again 
includes the GIF functions.

And... the functionality itself works fine (the GIF is written to STDOUT 
correctly, as it should).

The only problem is that the function doesn't seem to clean up, and 
leaves the temporary file it had created undeleted.

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


RE: [PHP] GD functions don't delete temporary files

2004-12-13 Thread Jay Blanchard
[snip]
 Yes. You will have to write your own clean-up code for things like
this.

I don't mean any user generated temporary files, I mean files which are 
created by the PHP function ImageGIF(). How should I even know which 
temporary file name GD chose in each case, or whether it created a temp 
file at all in a particular case?
[/snip]

Before the image is created you can get an array of things in the temp
file, then check for a new thing after the image is created. You can
verify the file type and if all is kosher, delete it.

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



Re: [PHP] GD functions don't delete temporary files

2004-12-13 Thread Matthew Weier O'Phinney
* Martin Holm [EMAIL PROTECTED]:
 Steve wrote:
  I am using GD image function with PHP (PHP 4.3.9 on RedHat 9). Today I 
  found that for all images I have created so far (using the ImageGIF() 
  function), there is a temporary file in /tmp with that image. The name 
  of the temp file is a 6 character combination of letters and digits, 
  e.g. jvc5Ne.
 
  To be sure it's not a config problem, I compiled again with minumum 
  options and minimum script
 
  ./configure --with-gd --with-zlib
 
  ?php
  $im = ImageCreate(20, 20);
  ImageGIF($im);
  ImageDestroy($im);
  ?
 
  But the problem is still there (CGI and CLI sapi tested). I used the 
  -n option, so php.ini can't cause the problem, either.
  Has anyone else experienced that?
 
 http://www.php.net/manual/en/function.imagegif.php -

 *Note: * Since all GIF support was removed from the GD library in 
 version 1.6, this function is not available if you are using that 
 version of the GD library.

Umm... did you read the OP? He's not asking about GIF support -- he's
asking why temporary files created by PHP + GD are not being deleted
when imagedestroy() is issued.

To the OP: from the manual, imagedestroy merely frees memory associated
with an image resource; it doesn't remove the temp file associated with
it. It's possible that PHP is either relying on the OS's /tmp cleanup
routines or Apache's temp file cleanup, or has set a large garbage
collection interval itself in its php.ini.

-- 
Matthew Weier O'Phinney   | mailto:[EMAIL PROTECTED]
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org

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



RE: [PHP] GD functions don't delete temporary files

2004-12-13 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 13 December 2004 16:14, Steve wrote:

  Seems like this is something that either the GD lib or PHP should
  be doing and not the user. Shouldn't this be reported as a bug?
 
 Yes, I also consider this a bug, unless it's something specific to my
 system. To find out, I posted this here.

This is in the NEWS file for PHP 4.3.10, due out any day now (currently in
RC2):

 Fixed bug #30658 (Ensure that temporary files created by GD are removed).

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] GD functions don't delete temporary files

2004-12-13 Thread Steve

Seems like this is something that either the GD lib or PHP should be doing and 
not the user. Shouldn't this be reported as a bug?
Yes, I also consider this a bug, unless it's something specific to my 
system. To find out, I posted this here.

Is nobody else out there using ImageGIF() with PHP 4.3.9? Can't believe 
it...

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


RE: [PHP] GD functions don't delete temporary files

2004-12-13 Thread Jay Blanchard
[snip]
 Before the image is created you can get an array of things in the temp
 file, then check for a new thing after the image is created. You can
 verify the file type and if all is kosher, delete it.

Seems like this is something that either the GD lib or PHP should be
doing and 
not the user. Shouldn't this be reported as a bug?
[/snip]

Not necessarily. Several languages require that you write your own
clean-up code for things like this.

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



RE: [PHP] GD functions don't delete temporary files

2004-12-13 Thread Jay Blanchard
[snip]
But the problem is still there (CGI and CLI sapi tested). I used the 
-n option, so php.ini can't cause the problem, either.
Has anyone else experienced that?
[/snip]

Yes. You will have to write your own clean-up code for things like this.

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



Re: [PHP] GD functions don't delete temporary files

2004-12-13 Thread Jason Wong
On Monday 13 December 2004 23:21, Jay Blanchard wrote:

 Before the image is created you can get an array of things in the temp
 file, then check for a new thing after the image is created. You can
 verify the file type and if all is kosher, delete it.

Seems like this is something that either the GD lib or PHP should be doing and 
not the user. Shouldn't this be reported as a bug?

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
The hands that help are better far than the lips that pray.
-- Robert G. Ingersoll
*/

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


Re: [PHP] GD functions don't delete temporary files

2004-12-13 Thread Steve

Not necessarily. Several languages require that you write your own
clean-up code for things like this.
Well, but then it should be at least mentioned in the documentation, 
right? Can you show me where it says that temp files are left over, or 
how to get the filename of the temp file so that the user can delete the 
file at all?

I've found nothing in the docs about that.
Regards,
Steve
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] GD functions don't delete temporary files

2004-12-13 Thread Richard Lynch
Jay Blanchard wrote:
 [snip]
 Yes. You will have to write your own clean-up code for things like
 this.

 I don't mean any user generated temporary files, I mean files which are
 created by the PHP function ImageGIF(). How should I even know which
 temporary file name GD chose in each case, or whether it created a temp
 file at all in a particular case?
 [/snip]

 Before the image is created you can get an array of things in the temp
 file, then check for a new thing after the image is created. You can
 verify the file type and if all is kosher, delete it.

This would be a recipe for disaster.

Other programs/processes will use /tmp to create GIF files, and there is
NO WAY to can be sure the one you want is the one you delete.

In particular, if your web site gets busy, your script may well be running
in parallel, with multiple instances of GIF files in /tmp, and there is
really really NO WAY AT ALL to know which file goes with which script
process.  Actually, you could *maybe* check enough info about the file,
such as process id owner stuff, if that's recorded...  But, really, this
is just going to be way more trouble than it's worth.

Don't do this.

Re-configure your server to delete /tmp files faster or more often.

Or, see if you can get imagegif() to save the files elsewhere by passing
in a valid filename *YOU* choose (possibly still in /tmp) as an argument.

*THEN* you could safely delete the file, since you chose the name.

-- 
Like Music?
http://l-i-e.com/artists.htm

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


Re: [PHP] GD functions don't delete temporary files

2004-12-13 Thread Richard Lynch
 Seems like this is something that either the GD lib or PHP should be
 doing and
 not the user. Shouldn't this be reported as a bug?

 Yes, I also consider this a bug, unless it's something specific to my
 system. To find out, I posted this here.

 Is nobody else out there using ImageGIF() with PHP 4.3.9? Can't believe
 it...

As a work-around, you may want to try http://php.net/imagepng

It's a superior format anyway, and OpenSource, and without the turbulent
history of GIF.

Of course, if you *NEED* GIF for some reason, you need GIF.  But if you
just want low-bandwidth images, PNG will suffice.

Some very very very very old browsers support GIF and not PNG, but nothing
that's even remotely current doesn't support PNG, as far as I know.

'Course, the PNG may have the same issue as well.

-- 
Like Music?
http://l-i-e.com/artists.htm

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