代码之家  ›  专栏  ›  技术社区  ›  think-serious

如何在azure节点函数中使用ghostscript

  •  0
  • think-serious  · 技术社区  · 7 年前

    我可以找到一些库,比如pdf thumbnail来将pdf转换为thumbnail,但是因为它们有二进制依赖关系(需要安装imagemagick和ghostscript),所以它在azure函数应用程序上不起作用。

    0 回复  |  直到 7 年前
        1
  •  0
  •   Hury Shen    7 年前

    在使用之前,您需要安装这两个软件包。请转到Azure门户上的功能,然后单击“平台功能”->“高级工具(Kudu)”。 enter image description here

    npm init
    

    enter image description here

    运行“npm init”命令后,它将提醒您提供包名称、版本、说明。。。。。您只需按enter键,它将生成包.json默认值。 enter image description here

    下一步,请输入“npm install”命令安装“imagemagick”包和“ghostscript”包。

    npm install imagemagick
    
    npm install ghostscript
    

    enter image description here

    之后,我们可以在azure函数的nodejs代码中使用这两个包

    const im = require('imagemagick');
    const gs = require('ghostscript-js');
    

    有关这两个软件包的更多信息,请参阅:

    https://www.npmjs.com/package/imagemagick

    https://www.npmjs.com/package/ghostscript-js