How to fix Error: Stream yields empty buffer in Node.js v14 + GM + ImageMagick

  docker, gm, image-resizing, imagemagick, node.js

How to fix Error: Stream yields empty buffer in Node.js v14.15.3?

Here is some code how I use ImageMagick to process images:

const gm = require('gm').subClass({ imageMagick: true });

const resize = (imageStream, width, height) =>
  new Promise((res, rej) => {
    gm(imageStream.on('error', rej))
      .resize(width, height, '>')
      .noProfile()
      .toBuffer('jpeg', (err, data) => (err ? rej(err) : res(data)));
  });

Error throws when image resolution higher than 4000×5000 pixels

ImageMagic Resource limits:
  Width: 64MP
  Height: 64MP
  List length: 18.446744EP
  Area: 3.2212GP
  Memory: 2GiB
  Map: 3GiB
  Disk: 10GiB
  File: 786432
  Thread: 2
  Throttle: 0
  Time: unlimited

Could someone help me with this?

Source: Docker Questions

LEAVE A COMMENT