Java 和 GraphicsMagick —— 它能工作吗?
我正在考虑在 Java 项目中使用 GraphicsMagick (http://www.graphicsmagick.org/)。有人有这方面的经验吗?关于如何开始的建议?似乎没有本地 Java 库,所以可能有点困难。
谢谢!
I am considering using GraphicsMagick (http://www.graphicsmagick.org/) in a Java project. Does anyone have any experience with this? Suggestions on how to get started? It seems like there isn't a native Java library so it may be a little more difficult.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我们使用 GraphicsMagick 和 Java 完成了我们的项目,这里的问答显然影响了我们的决定。虽然路很长,但我们最终还是完成了。我们非常努力地调整 GraphicsMagick 和 im4java 以获得我们想要的性能和可靠性。我想我应该回馈一下:
http://kennethxu.blogspot.com/2013/04/integrate-java-and- Graphicsmagick.html
We did our project with GraphicsMagick and Java, Q&A here obvious influence our decision. It's a long way but we eventually got it done. We tweaked both GraphicsMagick and im4java very hard to get the performance and reliability we want. Thought I should contribute back:
http://kennethxu.blogspot.com/2013/04/integrate-java-and-graphicsmagick.html
这绝对是可能的。看看 IM4Java,它是围绕各种 ImageMagick 之类工具(包括 GM)的命令行接口的 Java 抽象,感觉就像语言绑定一样。文档很少,但足够简单。显然,您的图像必须可以从操作系统访问(例如不在ResourceBundles内)。
It's definitely possible. Take a look at IM4Java, a Java abstraction around the commandline interfaces of various ImageMagick like tools (including GM) that feels like a language binding. Very little documentation, but sufficiently simple. Obviously your images have to be accessible from the OS (e.g. not inside ResourceBundles).
目前实现这一点的唯一合理方法是使用 Java 命令行 (runtime.exec)。您应该按照上面的建议使用 im4java 来执行此操作。 im4java 将使您能够使用 java 方法调用构建“gm 命令”字符串,它还提供了许多其他有用的功能。
与实际语言绑定相比,使用此技术的一大优点是简单性和可靠性。可靠性非常重要,尤其是当您的 Java 应用程序运行在基于 Java 的服务器或 servlet 引擎(如 tomcat)上时。原因是使用语言绑定时出现内存故障或其他错误可能会导致整个 Java 虚拟机崩溃。
Currently the only reasonable way to achieve this is by using the command line from Java (runtime.exec). You should use im4java to do this as suggested above. im4java will enable you to build up your "gm command" string using java method calls, it also provides a number of other useful features.
The big advantage of using this technique over actual language bindings is simplicity and reliability. Reliability is important especially if your Java app is running on a Java based server or servlet engine like tomcat. The reason being that a memory fault or other error while using language bindings could bring down the whole Java virtual machine.