在试图简单地缩略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');在不到1秒的时间里就跑了。
有人能尽可能详细地解释一下原因吗?还有,有什么理由我“不应该”使用第二种方法吗?还是有办法使gmagick扩展更快?
版本详细信息:
gmagick - 1.1.0RC3
GraphicsMagick - GraphicsMagick 1.3.17 2012年-10-13 Q8
发布于 2012-12-06 18:50:22
我发现'-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');这个职位帮了不少忙。
https://stackoverflow.com/questions/13713514
复制相似问题