title: How to convert image into webp using gm in node.js
body: <p>I was using <code>gm</code> for resizing images. Now I learn about <code>webp</code> to speed up my site. So I want to convert images into <code>webp</code> using same library. But the following does not work.</p>
  
  <p>How can I convert images into <code>webp</code> by <code>gm</code>?</p>
  
  <pre><code>function resize(last) {
      self.resize(width, height)
      .quality(80)
      .strip()
      .gravity('Center')
      .toBuffer(imageType, function(err, buffer) {
          if (err) last(err);
          else last(null, buffer);
      });
  },
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>gm('thumb_3.JPG')
    .toBuffer('webp', (err, buffer) =&gt; {
    fs.writeFile('buffer.webp', buffer, console.log)
  })
  </code></pre>
  
  <p>I use this code also</p>