简体   繁体   中英

using node.js with a remote GraphicsMagick server

I have node.js installed on one server. I have graphicsmagick https://github.com/aheckmann/gm installed on another server. The graphics files themselves are also stored on the graphicsmagick server. I want to install & setup the node gm module so that the work/processing is done on the graphicsmagick server. 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. 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 .

Something like this using 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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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