3

I am writing an image resize lambda function. It reads an object from s3 and uses jimp to resize it. When I run it, I get this error:

ERROR   (node:9) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

I have traced this down to the jimp in image.scaleToFit(). I don't get this error when running locally. Both are running node 14. I am assuming this is particular to AWS Lambda.

My failing code:

    const { Body } = s3Result;  //body is a buffer
    const jimpImage = await Jimp.read(Body).then((image) => {
      
      // debug tells me the bug happens here
      let imageResult = image.scaleToFit(width, height)

      imageResult = imageResult.quality(
        quality
      );
      return imageResult.getBufferAsync("image/jpg");
    });

Is there a workaround to this issue so I can keep using jimp?

Alternatives are welcome in the comments.

Thank you

Thinking Sites
  • 3,494
  • 17
  • 30

0 Answers0