简体   繁体   English

如何使用 Node.js、lambda function 压缩 Base 64 中的图像

[英]How to compress images in Base 64 with Node.js, lambda function

I want to compress images sent by the client side in Base 64 and pass to AWS to Store in S3 service.我想在 Base 64 中压缩客户端发送的图像并传递给 AWS 以存储在 S3 服务中。 But my problem is that the images are a lot so we want to compress the size of the images, but to AWS we send a base 64 data which contains the image so I want to apply an algorithm or a library in the Lambda function which compress the size of the image.但我的问题是图像很多,所以我们想压缩图像的大小,但是我们向 AWS 发送包含图像的 base 64 数据,所以我想在 Lambda function 中应用算法或库来压缩图像的大小。

The problem is not working with paths because there are libraries which do that.问题不在于路径,因为有库可以这样做。 I need a library for doing the compress via algorithm or functions.我需要一个库来通过算法或函数进行压缩。 Then it is stored in S3 so I should not have a decompress algorithm in another lambda function.然后它存储在 S3 中,所以我不应该在另一个 lambda function 中有解压缩算法。

I am working with nodejs and serverless for the lambdas.我正在为 lambdas 使用 nodejs 和无服务器。

Thanks in advance提前致谢

We do image processing using Lambda with nodejs.我们使用 Lambda 和 nodejs 进行图像处理。 One of the main functionality is to compress the images down to reasonable size.主要功能之一是将图像压缩到合理的大小。 What you need is to add ImageMagick as a Lambda Layer to compress the images on receiving them and upload to your S3 bucket.您需要添加 ImageMagick 作为 Lambda 层,以在接收图像时压缩图像并上传到您的 S3 存储桶。

Here's one such library you can use as a Lambda layer https://serverlessrepo.aws.amazon.com/applications/arn:aws:serverlessrepo:us-east-1:145266761615:applications~image-magick-lambda-layer这是一个这样的库,您可以将其用作 Lambda 层https://serverlessrepo.aws.amazon.com/applications/arn:aws:serverlessrepo:us-east-1:145266761615:applications~image-magick-

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM