php imagick压缩网络图片的方法

php imagick压缩网络图片的方法

  $rawimg    = $v['fengmiantu'];
            $watermark = new \Imagick();
            $info      = file_get_contents($rawimg);
            $watermark->readImageBlob($info);
            $watermark->scaleImage(300, 9999, true);
            $filename = $this->msectime() . rand(100, 999);
            $destpath = $this->getxiangmupath1() . '/' . $filename . '.jpg';
            $watermark->setImageFormat('jpg');
            $watermark->writeImage($destpath);
            $weburl='http://111/upload/caitonglianjie/' . $filename . '.jpg';
            $sql='update 111set fengmiantu=?,isupdate=1 where id=?';
            $this->commonexecute($sql,array($weburl,$v['id']));


如果遇到什么不懂的地方直接关注公众号留言(本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须在文章页面给出原文连接,否则保留追究法律责任的权利。)
作者:newmiracle
出处:https://www.cnblogs.com/newmiracle/

 
原文地址:https://www.cnblogs.com/newmiracle/p/15530068.html