PHP Imagick memory leak

后端 未结 4 710
庸人自扰
庸人自扰 2020-12-09 20:34

I have to render something with Imagick on PHP CLI. I have noticed that every 3-5 days the server memory gets full, so i can\'t even connet via ssh or ftp.

with memo

4条回答
  •  天涯浪人
    2020-12-09 21:31

    xdebug wasn't able to help me.. so i decided do look out for another solution. i came up with using image magic direct:

    $sourceImg = 'source.png';
    $destImg = 'dest.png';
    $background ='#00ff00';
    
    $command = "convert {$sourceImg}";
    $out = array();
    
    for($i=1;$i<=5;$i++){
        $command .= " -fill \"{$background}\" ";
        $command .= " -draw 'rectangle {$x1},{$y1} {$x2},{$y2}'";
    } 
    
    $command .= " {$destImg}";
    exec($command,$out);
    

    this solutions works way smoother then the imagick one. but i don't like the error-prone code.

提交回复
热议问题