serverless-image-resizing | Resizes images on the fly using Amazon S3 | REST library
kandi X-RAY | serverless-image-resizing Summary
kandi X-RAY | serverless-image-resizing Summary
Resizes images on the fly using Amazon S3, AWS Lambda, and Amazon API Gateway. Using a conventional URL structure and S3 static website hosting with redirection rules, requests for resized images are redirected to a Lambda function via API Gateway which will resize the image, upload it to S3, and redirect the requestor to the resized image. The next request for the resized image will be served from S3 directly.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of serverless-image-resizing
serverless-image-resizing Key Features
serverless-image-resizing Examples and Code Snippets
Community Discussions
Trending Discussions on serverless-image-resizing
QUESTION
When using the sharp image resize library https://github.com/lovell/sharp for node.js, the image is being rotated.
I have no code thats says .rotate(), so why is it being rotated and how can I stop it from rotating?
I'm using the serverless-image-resizing example provided by AWS: https://github.com/awslabs/serverless-image-resizing that uses lambda to resize images on the fly if the thumbnail does not exist
...ANSWER
Answered 2018-Feb-10 at 22:31The problem actually turned out to be this: when you resize an image, the exif data is lost. The exif data includes the correct orientation of the image, ie which way is up.
Fortunately sharp does have a feature that does retain the exif data, .withMetadata()
. So the code above needs to be changed to read:
QUESTION
I've just done this, makes images stored on s3 being resized on request and it works as charm: https://aws.amazon.com/tw/blogs/compute/resize-images-on-the-fly-with-amazon-s3-aws-lambda-and-amazon-api-gateway/
And I've just started reading articles of Lambda Edge: http://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html
But I'm still not sure what I should do with events: Viewer Request, Origin Request, Origin Response and Viewer Response.
The lambda function with gateway trigger I use for now is https://github.com/awslabs/serverless-image-resizing
...ANSWER
Answered 2017-Oct-16 at 22:16Lambda@Edge isn't quite a fit for image resizing, at this point. It is intended for more lightweight tasks, like header manipulation and small text-based response generation.
In Lambda@Edge, the deployment zip file is limited to 1 MiB, the container memory is limited to 128 MiB, the runtime is limited to 1 sec on the viewer side and 3 sec on the origin side, and although the available CPU capacity is not explicitly published it is some fraction of the capacity of 1 modern 2.3-2.4 GHz Xeon core. It's sufficient for sub-millisecond header rewrites, but not image resizing.
Now that Lambda@Edge has the ability to inspect the query string, it's conceivable that you could use it, instead of API Gateway, to invoke the second Lambda function that actually does the resize (invoke Lambda from Lambda) then convert the response from the API Gateway format into the CloudFront format, so the cost per invocation would potentially be lower (since a Lambda@Edge request costs less than an API Gateway request)... but it's not a direct substitute for what API Gateway + Lambda are doing in the established example. You would do this with an Origin Request trigger.
Lambda@Edge also can't return generated binary content (only UTF-8 character content), though that is not directly relevant to the resize example as implemented, since redirects are used to send the browser to the new target object.
It's very useful but not fully equivalent to API Gateway + Lambda.
QUESTION
I followed this blog https://aws.amazon.com/blogs/compute/resize-images-on-the-fly-with-amazon-s3-aws-lambda-and-amazon-api-gateway/
and this repo https://github.com/awslabs/serverless-image-resizing
To be able to resize images on AWS S3 on the fly. The bucket is created successfully. Whenever I upload image to the bucket, I can resize it from the url as indicated in the blog, everything works fine.
The problem is when an image is uploaded from the code (Ruby on Rails using paperclip), then the image can be accessed normally, however when trying with resizing url (e.g. /100x200/photo.png) I receive this in the browser as json response
...ANSWER
Answered 2017-Dec-25 at 10:48The error here that you put the required size before file name directly, you should put it before the whole file path.
Make sure that you follow this pattern:
http://$BucketWebsiteHost/$size/$imagePath
Example:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install serverless-image-resizing
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page