0

我开发了一个 node.js 工具,它从命令行使用 imagemagick。即,exec('my_imagemagick_commands')。将该工具交付给使用 Windows 的客户端的最佳方式是什么?也就是说,如何制作一个 Windows 安装程序,将 node.js、imagemagick 和工具(最好作为二进制文件,而不是源文件)安装在特定文件夹中?

4

1 回答 1

1

如果您想要一个简单的捆绑包...压缩下面的列表,在客户端上部署并将要处理的图像拖放到 yourtool.cmd 文件中(我正在为图像优化器做类似的事情)

捆绑:(将这些放在一个目录中)

  • 你的工具.cmd
  • 你的工具.js
  • 节点程序
  • node_modules/(如果适用)

你的工具.cmd

REM Get the drive/path the batch file is in
set batchdir=%~d0%~p0

REM Run tool for items dragged over...
"%batchdir%node.exe" "%batchdir%yourtool.js" %*

你的工具.js

// start at 2 for arguments passed...
// 0 is node.exe
// 1 is the js file run
for (var i=2; i<process.argv.length; i++) {
    var imagePath = process.argv[i];
    //do something with image...
}

对于其他对使用 node 的 imagemagick 感兴趣的人,您应该查看node-imagemagick

于 2013-02-27T23:15:21.437 回答