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.

    评论

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器