简体   繁体   English

在远程GraphicsMagick服务器上使用node.js

[英]using node.js with a remote GraphicsMagick server

I have node.js installed on one server. 我在一台服务器上安装了node.js。 I have graphicsmagick https://github.com/aheckmann/gm installed on another server. 我在另一台服务器上安装了graphicsmagick https://github.com/aheckmann/gm The graphics files themselves are also stored on the graphicsmagick server. 图形文件本身也存储在graphicsmagick服务器上。 I want to install & setup the node gm module so that the work/processing is done on the graphicsmagick server. 我想安装和设置节点gm模块,以便在graphicsmagick服务器上完成工作/处理。 However, after reading through the documentation, I don't see how to do this. 但是,在阅读了文档之后,我看不到该如何做。 Of course, I can install graphicsmagic on the same server as node, and have it work properly. 当然,我可以将graphicsmagic与节点安装在同一服务器上,并使它正常运行。 But I don't want to have the heavy image processing happening on the same server as node. 但是我不想在与节点相同的服务器上进行繁重的图像处理。 Is this possible to separate the two? 是否可以将两者分开?

the gm module is not a server, you need to write a service to manipulate the images with gm . gm模块不是服务器,您需要编写服务来使用gm操作图像。

Something like this using express.js: 使用express.js这样的东西:

var express = require('express');

var app = express.createServer();

app.get('/:image', function (req, res, next) {
  // set headers here

  gm('/path/to/my/' + req.params.image)
    .resize('200', '200')
    .stream(function (err, stdout, stderr) {
      if (err) next(err);
      stdout.pipe(res);
    });
});

app.listen(8000);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM