在我的项目中,我需要一个 Windows 可执行文件的图标文件 (.ICO)。我想从 SVG 生成该文件,因此它包含多个不同大小的图像。有没有可以为我做的maven插件?
我知道我可以在我的存储库中放一个图标文件,但源文件是 SVG 图像,所以我想避免这种情况。
我不认为有一些 Maven 插件。而且问题还超出了 Maven 本身。
你可以做的是:
I came across your question looking for a solution to a very similar problem. None of the answers given really suited me as I didn't want to get tied into running executables, so I wrote a pure Java Ant task (using Batik and image4j under the covers)
I've open sourced it at http://svg2ico.sourceforge.net/ - maybe you could call it from Maven?
您可以在网页上将 SVG 光栅化为 PNG,方法是使用Google 的 canvg将其推送到 Canvas 中,然后toDataURL()
在画布上使用以获取 base64 编码的 PNG 数据。然后,您需要对其进行解码。
或者,您可以使用任意数量的服务器端SVG-to-PNG 转换器。
没有比@Andrey 更好的答案,但第一步显示了更多选项。
batik -maven-plugin至少可以让您从 SVG 生成 PNG。不过,不确定如何生成 ICO。