ImageMagick 与 GD - 哪个更快、资源消耗更少并且生成更好的图像?
我需要在 ImageMagick 或 GD 库之间进行选择来执行以下图像处理任务:
- 将图像大小调整为多种尺寸
- 水印图像
如您所见,我不需要任何花哨的东西。我确信这两种工具都可以实现它们,所以如果一个工具比另一个工具有更多的额外功能,我并不关心。
我主要关心的是性能和质量。这 2 个工具中哪一个消耗的资源更少、速度更快并且生成的图像质量更好?
PS 我需要将它与各自的 PHP API 一起使用。
I need to choose between either ImageMagick or GD library for the following image manipulation tasks:
- resizing images into multiple sizes
- watermarking images
As you can see I don't need anything fancy. I'm sure both these tools can achieve them, so if one has more extra features than the other, I don't really care about.
My main concern is performance and quality. Which of these 2 tools consumes less resources, is faster and produces better quality images?
P.S. I need to use it with their respective PHP APIs.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
就图像质量而言,我倾向于 ImageMagick。它似乎可以产生比 GD2 更清晰/更高质量的图像(以更大的文件大小为代价)。ImageMagick
也不受 PHP 内存限制的约束。
I would lean towards ImageMagick as far as image quality goes. It seems to produce considerably sharper/higher-quality images than GD2 (at the expense of larger filesize.)
ImageMagick is also not bound by PHP's memory limit.
如有疑问,请使用 ImageMagick。我没有观察到速度和资源使用方面有任何大的差异,但 IM 在许多方面更加灵活,质量更好(尽管您可以期望两个库的水印效果都不错),并且支持 更多格式。
许多使用 GD 复杂或无法实现的高级操作使用 ImageMagick 可以轻松完成。
另一方面,许多托管提供商对 ImageMagick 的支持不如 GD,因此您需要添加相当大的依赖项。根据您的项目的性质,这可能是也可能不是问题。
If in doubt, use ImageMagick. I haven't observed any big differences in speed and resource usage, but IM is way more flexible, better in quality in many areas (although you can expect decent results in watermarking from both libraries), and supports way more formats.
Many advanced operations that are complex or impossible to achieve with GD are easy to do with ImageMagick.
On the other hand, ImageMagick is not supported as well as GD by many hosting providers, so you'd be adding a sizeable dependency. Depending on the nature of your project, that may or may not be a problem.
我已经构建了 GD 和 ImageMagick 库。如果使用得当,两者都可以正常工作并产生相同尺寸的图像。然而,ImageMagic 提供了更多开箱即用的选项,这也是我现在所倾向于的。
此外,ImageMagick 作为 bash 脚本或其他终端函数的独立工具非常有用,这意味着您所学到的知识在 PHP 之外也很有用。
I have built GD and ImageMagick libraries. Both work just fine and produce the same size images if used right. However, ImageMagic comes with a lot more options out of the box and is what I lean towards now.
In addition, ImageMagick works great as a stand-alone for bash scripting or another terminal functions which means what you learn is useful outside of PHP.