图片上传和操纵API花更多的时间用于更高分辨率的图像更高、图片上传、图像、分辨率

2023-09-11 10:04:20 作者:懂不你界世的比逗

我目前的流量我下面的的图片的上传操作上在 S3存储如下:

My Current flow that I am following for image upload and its manipulation on the S3 bucket is as follows:

在图片被上传到 S3桶。 检索图像保存的图像中的缓冲区 S3桶 使用克和的 ImageMagick的 NPM模块。 保存与原分机调整后的图像缓冲区作为的 S3斗。 Image is uploaded into an S3 Bucket. Retrieving the image buffer of the saved image in the S3 Bucket. Resizing of the image buffer using gm and imagemagick npm module. Saving the resized image buffer with the original extension as a new image in the S3 Bucket.

由于图像尺寸增大使那些API 响应 time.It需要的 3 秒的API来给予回应按照上述流程为300 KB的图像和30秒为15 MB或更多的图像,同时。

As the image size increases so those the API response time.It takes 3 secs for the API to give a response while following above workflow for a 300 KB image and 30 secs for a 15 MB or more image.

我不知道我的流程是否正确。我的要求是,我需要减少我的API响应时间,同时上传15个或更多MB的图像。有人可以给我建议如何实现这一目标?

I don't know if my flow is correct or not. My requirement is that I need to reduce my API response time while uploading a 15 or more MB image. Can somebody suggest me how to achieve this?

修改

要弄清楚,我上传它我从高级REST客户端(铬插件)把它发送到我的API一个15 MB的文件。该图像文件当前present在我的本地系统。我目前正在 JPG PNG 图像。我想通过的图像的大小调整到两个较大和较小的尺寸降低了宽高比的。我写的API在节点JS它遵循上述流程。

To make it clear I am uploading a single 15 MB file which I am sending it from Advanced Rest Client (a chrome plugin) to my API. The image file is currently present in my local system. I am currently working on jpg and png images. I want to resize the image to both bigger and smaller sizes by reducing the width to height ratio. The API that I Have written is in Node JS which follows the above workflow.

推荐答案

好像上传和下载大图从S3需要花费大量的时间。

Seems like upload and download big image from S3 takes a lot of time.

您可以做一些优化:

尝试使用实:graphicsmagick 包,在普通情况下,它的速度更快了ImageMagick的(最新版本)

请调整大小/前优化运营 上传到S3,并上传在最后一步 Try to use graphicsmagick package, in common cases it's faster that imagemagick (latest versions)

Make resize / optimize operations before uploading to S3 and upload at last step

如果这是不可能的 - 尽量使用流下载 - 调整 - 上传到S3。只是管道请求流通用模块,并写入管道AWS S3

If it's not possible - try to use Streams for downloading - resizing - uploading to S3. just pipe request stream to gm module and write pipe to AWS S3