ImageMagik filling my temp dir

MagickWand for PHP is an object-oriented PHP interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning MagickWand for PHP.
Post Reply
iambaz

ImageMagik filling my temp dir

Post by iambaz »

Hi,

I recently upgraded my image gallery site to resize photos with imagemagik and magickwand for php. It worked fine until I started getting a problem with an error 28 on the site. The cause of this seems to be my servers temp directory filling up due to imagemagik. I use something like:

$resource = NewMagickWand();
MagickReadImage($resource, $_FILES['file1']['tmp_name']);
$resource = MagickTransformImage($im, '0x0', "{$newwidth}x{$newheight}" );
MagickWriteImage($resource, $name);

I presume i need some kind of line after this to delete the temporary file?

Help would be apreciated

Thanks
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: ImageMagik filling my temp dir

Post by magick »

Add DestroyMagickWand() after you are done with it. This destroys any resources associated with the wand including any temporary files.
iambaz

Re: ImageMagik filling my temp dir

Post by iambaz »

Ah! Thanks mate
iambaz

Re: ImageMagik filling my temp dir

Post by iambaz »

Unfortunately this hasn't fixed my problem. We are still getting sporadic error 28 messages. This has become a major issue for us as it's crashing the site quite often.

The site is a public image gallery and people are uploading photos all thetime. Generally everything is working fine but every so often the temp dir fills up with the following files:

Image
Image

There is no real pattern to these crashes, but as you can see, the files fill up at the same time.

I use the above code to upload the files - complete with destroyMagickWand() after the upload code.

Any information or hints regarding my issue would be very useful. I'm starting to think it may be malicious actions, but I am unaware how to combat them if they are.

Thanks in advance
mrBlaQ
Posts: 17
Joined: 2008-02-05T12:19:00-07:00

Re: ImageMagik filling my temp dir

Post by mrBlaQ »

Try checking your php error logs for 'time limit exceeded' messages (your exact wording may vary) Perhaps these temp files are left over from dead processes that took too long to resize or whatever other operation you're dealing with.
Post Reply