douyan0732 2018-01-19 11:53
浏览 651

ImageMagick创建了大量的临时文件

I'm using imagick for GIF file uploads with resizing. Im used to upload filesizes ranges from 5mb -15mb Due to huge tempory files my site gets crashed and also images are not getting converted correctly. How can I fix this?

$imagick =  new Imagick($_FILES['file']['tmp_name']);

foreach ($imageFolders as $imageFolder => $size) {

    if ($imagick->getImageWidth() > $size['minWidth']) {
        $width = $size['maxWidth'];
        $height = $size['maxWidth'];
    } else {
        $width = $imagick->getImageWidth();
        $height = $imagick->getImageHeight(
    }

    $imagick = $imagick->coalesceImages();

    foreach($imagick as $frame){
        $frame->thumbnailImage($width , $height ); 
        $frame->setImagePage($width , $height , 0, 0); 
    }

    $imagick = $imagick->deconstructImages();
    $imagick->writeImages($imagePath, true);

}

$imagick->clear();
  • 写回答

1条回答 默认 最新

  • douyan8413 2018-01-19 16:10
    关注

    I am facing the same issue, it is related to imageMagic. I got this link https://github.com/ImageMagick/ImageMagick/issues/395. To fix this, I have created a cronjob which runs every minute and deletes the tmp file. Here is the shell script

    find /tmp -maxdepth 1 -type f -name "magick-*" -delete
    

    If anyone has better alternative, please suggest.

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料