php – 为什么gmagick :: thumbnailimage比exec(gm)慢?
发布时间:2020-12-13 22:46:30 所属栏目:PHP教程 来源:网络整理
导读:在尝试简单地用 PHP缩略图像我用过: $image = new Gmagick('/tmp/large.jpg');$image-thumbnailImage(0,100);$image-writeImage('/tmp/small.jpg'); 在大约15秒内跑了. 然后我尝试了: exec('gm convert -size 200x100 /tmp/large.jpg -resize 200x100 +pro
在尝试简单地用
PHP缩略图像我用过:
$image = new Gmagick('/tmp/large.jpg'); $image->thumbnailImage(0,100); $image->writeImage('/tmp/small.jpg'); 在大约15秒内跑了. 然后我尝试了: exec('gm convert -size 200x100 /tmp/large.jpg -resize 200x100 +profile "*" /tmp/small.jpg'); 在不到一秒的时间内跑了 有人可以尽可能详细地解释原因吗?另外,有什么理由我“不应该”使用第二种方法吗?或者有没有办法让gmagick扩展更快? 版本细节: gmagick – 1.1.0RC3 解决方法
我发现’-size’选项不是php缩略图方法的一部分.一旦我手动添加它,以下PHP代码实际上比命令行稍快.
$image = new Gmagick(); $image->setSize(200,200); // This sets the size of the canvas. Should be roughly twice the dimensions of the desired thumbnail for antialiasing to work well. $image->readImage('/tmp/large.jpg'); $image->thumbnailImage(0,100); $image->writeImage('/tmp/small.jpg'); This post帮助了很多. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |