如何使用 ColdFusion 的 ImageMagick

发布于 2024-07-17 06:51:25 字数 650 浏览 4 评论 0 原文

ColdFusion 有一个很棒的 cfimage 标签,可以完美运行。 但是,它不允许操纵矢量格式。 这导致我继续寻找第三方工具来执行一些“图像魔法”。

我决定尝试使用 ImageMagick 和 ColdFusion。 我读过几篇文章,内容是“我曾经使用 ColdFusion 的 ImageMagick 工作了 X 年”。 这很鼓舞人心,但在遇到问题时并不是特别有用。

我已尝试以下操作:

  1. cfexecute 带参数运行命令行“转换”命令。 ColdFusion 页面不产生任何内容 - 只是一个空页面。 图像未转换。 没有例外,也没有文本发送到浏览器。 ImageMagick 命令“convert image.eps image.jpg”可以从 Windows 命令行完美运行,但不能从 ColdFusion 运行。

  2. Im4java 和 JMagick 包装器直接从 Java 对象运行 IM 命令。 我使用 CreateObject 函数创建了 Java 对象,并尝试执行它的方法,但只得到了不同类型的 Java 错误,例如“无法将 image.jpg 转换为整数”。

欢迎任何建议。

谢谢!

PS:我的第一个“stackoverflow”:)

ColdFusion has a great cfimage tag that works perfectly. However, it doesn't allows vector formats to be manipulated. This caused me to continue searching for 3rd party tools to do some "image magic".

I decided to try ImageMagick with ColdFusion. I've read couple of posts that was saying 'I used to work with ImageMagick from ColdFusion for X years'. This is inspiring, but not particularly useful when bumping into problems.

I've tried the following:

  1. cfexecute with arguments to run command-line 'convert' command. ColdFusion page produces nothing - just an empty page. Images are not converted. No exceptions or text being out to browser. ImageMagick command 'convert image.eps image.jpg' runs perfectly from Windows command line, but not from ColdFusion.

  2. Im4java and JMagick wrappers to run IM commands directly from Java objects. I created Java objects with CreateObject function and was trying to execute it's methods, but got only different types of Java errors like 'cannot convert image.jpg to integer'.

Any suggestions welcome.

Thanks!

PS: my first 'stackoverflow' :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

土豪 2024-07-24 06:51:25

经过一番尝试和失败后,我让 ImageMagick (IM) 为我工作。 让我简要描述一下如何使用 Coldfusion 的 ImageMagick:

  1. 在盒子上安装 ImageMagick 和 Ghostscript。 Ghostscript 用于矢量图形操作。
  2. 利用CFEXECUTE标签调用带参数的IM:

注释

: 在“名称”属性中写入 ImageMagic 可执行文件之一(例如,convert.exe)的完整路径。

b. 编写源图像和目标图像的完整路径。 请注意附加引号 - 如果完整路径包含空格 (C:\Program Files),则必须将每个图像名称括在引号中。 由于 Coldfusion 解析“arguments”属性,因此您必须使用附加引号来筛选引号,例如 -“”C:\Program Files\“”。

C。 使用超时属性,在 Coldfusion 进一步执行模板之前留出一些时间让 ImageMagic 生成结果。

谢谢大家的回答和兴趣。

PS:其他提示:

  • ImageMagick 提供多种格式可供使用 - 从常规 JPEG 到 Photoshop *.psd 文件。 然而,对于像 Encapsulated Postscript *.eps 这样的矢量格式,您需要安装 Ghostscript;
  • 您可以通过小技巧处理 Adob​​e PDF 和 Adob​​e Illustrator (*.ai) 格式 - 将它们重命名为 *.eps 并让 ImageMagick 将它们视为 Encapsulated Postscript 矢量文件。 这至少允许将矢量文件转换为位图;
  • 进程是资源密集型的,请考虑增加 Coldfusion 的 JVM 内存限制。

After some tries and fails, I made ImageMagick (IM) work for me. Let me briefly describe how to work with ImageMagick from Coldfusion:

  1. Have ImageMagick and Ghostscript installed on box. Ghostscript is used for vector graphics manipulation.
  2. Make use of CFEXECUTE tag to call IM with parameters:

    <cfexecute name="#FullIMPath#" timeout="60" arguments="""#ExpandPath(filename1)#"" ""#ExpandPath(filename2)#""" />

Comments:

a. Write full path to one of ImageMagic executables (for example, convert.exe) in 'name' attribute.

b. Write full paths for source and target images. Please note additional quotes - if full path has spaces (C:\Program Files), you have to surround each image name in pair of quotes. Since Coldfusion parses 'arguments' attribute, you have to screen a quote with additional quote, like this - ""C:\Program Files\"".

c. Use timeout attribute, to allow some time for ImageMagic to produce results before Coldfusion goes further with template execution.

Thank you all for answers and interest.

PS: Additional hints:

  • ImageMagick offers many formats to work with - from regular JPEGs to Photoshop *.psd files. However, for vector formats like Encapsulated Postscript *.eps, you need to have Ghostscript installed;
  • you may work with Adobe PDF and Adobe Illustrator (*.ai) formats with small hack - rename them to *.eps and let ImageMagick treat them like Encapsulated Postscript vector files. This allows at least to convert vector files to bitmaps;
  • process is resource intensive, consider increasing JVM memory limits for Coldfusion.
揪着可爱 2024-07-24 06:51:25

cfexecute 应该可以工作。

cfexecute should work.

余生再见 2024-07-24 06:51:25

还要考虑 cfx_image ..它是一个激发 cfimage 灵感的优秀标签。 我相信它也可以处理矢量图像。 没有什么是我做不到的。

Also consider cfx_image .. it is an excellent tag that inspired cfimage. I believe it also does vector images. There isn't much I haven't been able to do with it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文