在 php 中连接两个图像的最快方法是什么?
我需要在 php 中垂直和水平连接图像(两个或更多)。最快的方法是什么?
obs:我不想使用非本地库,
这是另一个疑问。生成的图像是否具有图像大小的总和,或者是否会更大?
谢谢 (:
i need to concatenate images in php (two or more), both vertically and horizontally. What's the fastest way to do that?
obs: i don't want to use non-native libraries
another doubts. will the resulting image have the sum of the images sizes or could it be significantly bigger?
thanks (:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
现在我只是在堆栈溢出编辑器中对此进行了编码,并且尚未经过测试,但这应该使用所有本机库,并且可能是最快的。只需将 image1 复制并重新采样到前半部分(宽度方向),然后将第二个图像复制到后半部分(宽度方向),如果您想通过堆叠高度来完成此操作,则只需更改 dest_h 的位置即可。这是一些信息... http://php.net/manual/en/function。 imagecopyresampled.php
哦,顺便说一句,这是为了保存图像。这就是我假设你所做的。否则,将两张带有标签的图像相邻堆叠的答案将是最快的。
至于最终的图像,请记住。如果它们水平放置,则宽度将为
$w1 + $w2
,高度将为math.max($h1, $h2)
,如果图像则相反垂直堆叠Now i did just code this in stack overflows editor and it is untested, but that should use all native libraries and probably be the fastest. Just copies and resamples the image1 into the first half (width wise) and then copies the second image into the second half (width wise), if you wanted to do it by stacking on height, it would just be changing where the dest_h is. Here is some info... http://php.net/manual/en/function.imagecopyresampled.php
oh BTW, that was for saving an image. That is what i am assuming your doing. Else the answer about stacking 2 images next to eachother with tags would be the fastest.
As far as the resulting image, remember. If they are laid horizontally, then the width would be
$w1 + $w2
and the height would bemath.max($h1, $h2)
and opposite if the images are stacked vertically