在 Groovy 中从两个源 png 创建合成图像
我见过一些 Groovy 代码,可以让您组合图像和文本,但不能组合图像和图像...
本质上,我需要在地图上的某些坐标处叠加符号:我有一些地图和符号作为 .png 文件。我可以毫无问题地进行坐标计算,所以问题更多的是,给定两个透明 png,如何在不丢失透明度的情况下组合它们? (地图和符号可能都需要保留其透明度)。
理想情况下,我需要一个函数,类似的
combinePngImage(background_src, foreground_src, foreground_x, foreground_y)
函数会返回两者的 png 组合,给定前景图像的左上角、右上角坐标。
[背景:我有一些地图和符号作为 .png 文件存储在 FileMaker 的容器字段中,我需要将它们合并到 FileMaker 解决方案中。我尝试过使用 ImageMagick 和命令行来完成此操作,但我突然意识到这可能可以使用 ScriptMaster 来完成,ScriptMaster 使用 Groovy 创建外部函数。 ]
任何指点感激不尽!
I've seen some Groovy code that lets you combing images and text, but not images and images ...
Essentially, I need to overlay symbols at certain coordinates on maps: I have some maps and symbols as .png files. I can do the coordinate calcs no problem, so the issue is more a case of, given two transparent pngs how do I combine them without losing transparency? (Both the map and the symbol may need to retain their transparency).
Ideally I need a function, something like
combinePngImage(background_src, foreground_src, foreground_x, foreground_y)
that would return a png combination of the two, given the top left, top right coordinates of the foreground image.
[Background: I have some maps and symbols as .png files stored in container fields in FileMaker that I need to combine within a FileMaker solution. I've tried looking in to doing it using ImageMagick and the command line, but it suddenly struck me that this may be something that could be done using ScriptMaster, which uses Groovy to create external functions. ]
Any pointers gratefully received!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,不管它的价值如何——这里有一些拼凑起来的食谱片段,似乎可以完成这项工作——任何关于(糟糕的)编码风格的评论都会受到热烈欢迎。
给定 ScriptMaster 调用
所需的代码是:
Okay, for what it's worth - here's some cobbled together cookbook snippets that seem to do the job - any comments on the (poor) coding style greatfully received.
Given a ScriptMaster call to
the required code is:
您可以尝试使用 Im4java(一个纯 Java ImageMagick API),而不是使用 ImageMagick 命令行。
Rather than using the ImageMagick command-line, you could try using Im4java, a pure Java ImageMagick API.