Asynchronous GraphicsMagick For Node

后端 未结 3 2011
甜味超标
甜味超标 2020-12-21 13:12

I am using GraphicsMagick for node. I basically crop the photos and retrieve the exif data of the photos uploaded by the user. I don\'t want to block the flow of request wai

3条回答
  •  再見小時候
    2020-12-21 13:34

    And here is how to promisify gm:

    var Promise = require('bluebird');
    var gm = require('gm').subClass({imageMagick: true});
    Promise.promisifyAll(gm.prototype);
    
    gm('1.jpg')
      .resize(240, 240)
      .noProfile()
      .writeAsync('1b.jpg')
      .then(function () {
        console.log('done');
      });
      .catch(function (err) {
        console.log(err);
      });
    

    https://github.com/aheckmann/gm/issues/320

提交回复
热议问题