admin管理员组文章数量:1429064
I'm trying to create a new PNG file to serve back to clients via HTTP (as a response type image/png)
The new file is created by concatenating 3 base PNG files and adding a custom text
in the middle of the image.
Problem is, there no built-in library in nodejs to do this. I spent a couple of hours searching and to my surprise, there is no pure JS
library to do this. The closest thing is node-pngjs but it lacks the ability to add text. I understand that the text part is plicated since it's somewhat dependent on the OS (fonts installed, DLLs to interface with said fonts, etc).
There are other node modules that are wrappers around imageMagick (gm) and GTK (canvas) but unfortunately imageMagick is 155MB of binaries, and to use canvas you need to pile from source, install python
and VS 2010 C++ Express Edition
and it does not work on the lastest version of GTK.
The best I got right now is to write an .NET assembly and use it from inside node via edge.js, but that will require both Windows OS and .NET framework on the server.
Again, the plicated part here is adding the text inside the image.
Any suggestion on how to get this working without a sh**load of external dependencies?
I'm trying to create a new PNG file to serve back to clients via HTTP (as a response type image/png)
The new file is created by concatenating 3 base PNG files and adding a custom text
in the middle of the image.
Problem is, there no built-in library in nodejs to do this. I spent a couple of hours searching and to my surprise, there is no pure JS
library to do this. The closest thing is node-pngjs but it lacks the ability to add text. I understand that the text part is plicated since it's somewhat dependent on the OS (fonts installed, DLLs to interface with said fonts, etc).
There are other node modules that are wrappers around imageMagick (gm) and GTK (canvas) but unfortunately imageMagick is 155MB of binaries, and to use canvas you need to pile from source, install python
and VS 2010 C++ Express Edition
and it does not work on the lastest version of GTK.
The best I got right now is to write an .NET assembly and use it from inside node via edge.js, but that will require both Windows OS and .NET framework on the server.
Again, the plicated part here is adding the text inside the image.
Any suggestion on how to get this working without a sh**load of external dependencies?
Share Improve this question asked Mar 24, 2014 at 13:55 NickNick 72710 silver badges20 bronze badges1 Answer
Reset to default 3Yes you are correct, the Node.js support for image processing libraries is weak, most are the wrappers of some CLI application.
The solution that I would use involves PhantomJS which has the canvas and svg support, you could use these features. It's lighter than the other options and does not require external applications to be installed. http://phantomjs/quick-start.html
本文标签: javascriptNodejs create a PNG image with text insideStack Overflow
版权声明:本文标题:javascript - Nodejs create a PNG image with text inside - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745534025a2662190.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论