在Node.js中的AWS Lambda上使用.overlayWith()时出错

时间:2018-08-31 08:26:40

标签: node.js amazon-web-services amazon-s3 aws-lambda sharp

我在AWS Lambda上使用了Sharp,并且效果很好,但是,当我尝试添加水印时,它会给出一个错误。

https://{vstscollectionuri}/{projectname}/_build/results?buildId={buildid}&_a=summary

它在本地但在AWS lambda上运行良好;它给出了这个错误

The input file is missing or of an unsupported image format

水印和lambda函数位于同一存储桶中

https://s3.ap-south-1.amazonaws.com/yallamotor-development-assets/watermark.png

我该如何解决

1 个答案:

答案 0 :(得分:1)

要添加水印,您可以使用Python 3.6.7 (default, Oct 22 2018, 11:32:17) [GCC 8.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> def f(): ... print("Hello") ... >>> callback = f >>> callback() Hello >>> callback2 = lambda: f >>> callback2() <function f at 0x7fafacc10c80> >>>

composite()

然后您可以使用FTP和缓冲区获取水印,然后在 let sharp = require('sharp'); let imageBuffer = null; await sharp(buffer) .composite([{ input: './watermark.png', gravity: 'center' }]) .sharpen() .withMetadata() .toBuffer() .then(function(outputBuffer) { imageBuffer = outputBuffer; }); return imageBuffer; 中传递缓冲区。