Huge ImageMagick Temporary File


Okay, so lately I’ve been getting a lot of 500 Internal Servers due to my /tmp folder filling up and preventing uploads. However, when I look inside it, the culprit is always a huge file called “magick-XXXUSKnT” or similar, which I believe is coming from ImageMagick.

However, the file is often huge, far larger even than any images my site handles, so it’s clearly growing in size due to some kind of error, filling up /tmp then failing such that ImageMagick closes without discarding it. Even stranger is that ls often measures their size as several hundred megabytes, even though my /tmp folder has a limit of 128mb (I’m on a VPS).

Does anyone know what might be causing this? I’ve activated a more aggressive /tmp cleaning cron job to run every 15 minutes, to hopefully clear these files more quickly, but I really should figure out why they’re appearing in the first place.


What tool do you use to upload images? And how big ARE these images?


It’s not really a tool, but rather I have a phpBB forum that allows attachments, so I don’t know which specific content is triggering the problem. I’ve setup a script that will grab a copy of any offending files before clearing them, so I can hopefully have a look next time it happens (though I don’t know what format they’re stored in, I’m hoping it’s just some image format).

My PHP installation and forums are both configured to not allow attachments larger than 32mb, but images are further limited to 10mb so no individual image larger than this should be getting processed. As far as I know phpBB only invokes ImageMagick in order to resize images and generate thumbnails, which don’t really seem like they should be big operations.


It kind of is, because ImageMagick will use the tmp space to make the resized images and then copy them up to the right place in phpBB, and depending on how phpBB does that (single stream or all at once), that may be why it’s overloaded. That’s why I wanted to know how big the images are. When we moved WordPress to ImageMagick, I had a lot of fun breaking it with 10meg images :slight_smile: