Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

imagemagick doesn't delete tmp files

I have an app that uses Carrierwave, S3 and rmagci. more or less following http://railscasts.com/episodes/253-carrierwave-file-uploads but just upload to S3 instead of local.

I noticed the temp files in public/uploads/ does not get deleted after an image gets created. This causes my computer to feel up over time and crash.

I looked around and the only solution i found was to write a cron job to delete them http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=15960

any idea if there is a better way to do this in the code rather than a cronjob?

like image 796
Matilda Avatar asked Aug 09 '12 00:08

Matilda


3 Answers

As of January 2013, there is no official way to delete temporary files, so imagemagic leaves you to do it yourself. I also use a cron job that runs every 20 minutes since the temporary files are 10+ GB in size.

like image 151
Bashevis Avatar answered Nov 15 '22 10:11

Bashevis


It means your ImageMagick installation is NOT functioning properly!

The fact that it leaves magick-* files in tmp says that ImageMagick process died and that's why it didn't delete those files. You should configure memory limits etc. Refer http://www.imagemagick.org/script/resources.php

like image 26
Vadym Avatar answered Nov 15 '22 09:11

Vadym


I've had this problem for a period of time, my code issue was that I didn't use the destroy function:

$im->destroy();

When calling the destroy function it will delete the temp files that are made under the /tmp directory. This is for PHP and maybe it will help someone.

like image 3
Khaled Hasania Avatar answered Nov 15 '22 08:11

Khaled Hasania