Use node gm with promises and buffers
<p>I've been trying to use gm with Bluebird like this:</p>

<pre><code>var gm = require('gm');
var bluebird = require('bluebird');
gm = bluebird.promisifyAll(gm);
</code></pre>

<p>But then, when I try something like this:</p>

<pre><code>gm(req.file.buffer)
     .crop(tWidth, tHeight, tWidth/2, tHeight/2)
     .gravity('Center')
     .toBuffer()
  .then(...)
</code></pre>

<p>I get this error: </p>

<blockquote>
  <p>gm().toBuffer() expects a callback.</p>
</blockquote>

<p>If I only promisify the buffer method:  </p>

<pre><code>bluebird.promisify(gm(req.file.buffer)
        .crop(tWidth, tHeight, tWidth/2, tHeight/2)
        .gravity('Center')
        .toBuffer)()
        .then(buff =&gt; {...})
</code></pre>

<p>I get this error:</p>

<blockquote>
  <p>TypeError: this.stream is not a function
  6:36:21 AM web.1 |      at toBuffer (/Users/danielrvt/IdeaProjects/twe-backend/node_modules/gm/lib/command.js:162:17)</p>
</blockquote>

<p>If I don't use promises, it works just fine.</p>