1

I tried to use gm to resize a big avatar image to 64 * 64.
The express function is an async function and I tried to promisify all methods by the following codes:

import gm_origin from 'gm'
import Promise from 'bluebird';
const gm = Promise.promisifyAll(gm_origin);

...
const processThumb = async (req, res) => {
  
  const thumbFile = gm(req.file.buffer).resize(config.thumbSize);
  const thumbBuffer = await thumbFile.toBufferAsync('JPG');
  ...
}

But the API does not respond at all.
So I set a breakpoint to the line and it is saying that thumbFile does not have 'goBufferAsync' method. Is anybody know how to promisify all methods of 'gm'?
Colin Wang
  • 6,778
  • 5
  • 26
  • 42

0 Answers0