All Projects → emaesen → Aws Lambda Resize Images

emaesen / Aws Lambda Resize Images

Licence: mit
AWS Lambda function to generate a set of resized images (large, medium, small)

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Aws Lambda Resize Images

Aws Serverless Samfarm
This repo is full CI/CD Serverless example which was used in the What's New with AWS Lambda presentation at Re:Invent 2016.
Stars: ✭ 271 (+4416.67%)
Mutual labels:  aws, aws-lambda, lambda
Mangum
AWS Lambda & API Gateway support for ASGI
Stars: ✭ 475 (+7816.67%)
Mutual labels:  aws, aws-lambda, lambda
Aws Auto Cleanup
Open-source application to programmatically clean your AWS resources based on a whitelist and time to live (TTL) settings
Stars: ✭ 276 (+4500%)
Mutual labels:  aws, aws-lambda, lambda
Webiny Js
Enterprise open-source serverless CMS. Includes a headless CMS, page builder, form builder and file manager. Easy to customize and expand. Deploys to AWS.
Stars: ✭ 4,869 (+81050%)
Mutual labels:  aws, aws-lambda, lambda
Serverless Plugin Warmup
Keep your lambdas warm during winter. ♨
Stars: ✭ 814 (+13466.67%)
Mutual labels:  aws, aws-lambda, lambda
Serverless Chrome
🌐 Run headless Chrome/Chromium on AWS Lambda
Stars: ✭ 2,625 (+43650%)
Mutual labels:  aws, aws-lambda, lambda
Aws Lambda Cpp
C++ implementation of the AWS Lambda runtime
Stars: ✭ 300 (+4900%)
Mutual labels:  aws, aws-lambda, lambda
Components
The Serverless Framework's new infrastructure provisioning technology — Build, compose, & deploy serverless apps in seconds...
Stars: ✭ 2,259 (+37550%)
Mutual labels:  aws, aws-lambda, lambda
Lambda Packages
Various popular python libraries, pre-compiled to be compatible with AWS Lambda
Stars: ✭ 713 (+11783.33%)
Mutual labels:  aws, aws-lambda, lambda
Archive aws Lambda Go
A fast and clean way to execute Go on AWS Lambda.
Stars: ✭ 710 (+11733.33%)
Mutual labels:  aws, aws-lambda, lambda
Apilogs
Easy logging and debugging for Amazon API Gateway and AWS Lambda Serverless APIs
Stars: ✭ 216 (+3500%)
Mutual labels:  aws, aws-lambda, lambda
Archive aws Lambda Go Shim
Author your AWS Lambda functions in Go, effectively.
Stars: ✭ 799 (+13216.67%)
Mutual labels:  aws, aws-lambda, lambda
Retinal
🏙 Retinal is a Serverless AWS Lambda service for resizing images on-demand or event-triggered
Stars: ✭ 208 (+3366.67%)
Mutual labels:  aws, aws-lambda, image-processing
Algnhsa
AWS Lambda Go net/http server adapter
Stars: ✭ 226 (+3666.67%)
Mutual labels:  aws, aws-lambda, lambda
Aws Lambda Power Tuning
AWS Lambda Power Tuning is an open-source tool that can help you visualize and fine-tune the memory/power configuration of Lambda functions. It runs in your own AWS account - powered by AWS Step Functions - and it supports three optimization strategies: cost, speed, and balanced.
Stars: ✭ 3,040 (+50566.67%)
Mutual labels:  aws, aws-lambda, lambda
Lambdaguard
AWS Serverless Security
Stars: ✭ 300 (+4900%)
Mutual labels:  aws, aws-lambda, lambda
Serverlessish
Run the same Docker images in AWS Lambda and AWS ECS
Stars: ✭ 177 (+2850%)
Mutual labels:  aws, aws-lambda, lambda
Micro Aws Lambda
A 7KB and 0 dependencies AWS Lambda library which supports middleware and easy debug.
Stars: ✭ 181 (+2916.67%)
Mutual labels:  aws, aws-lambda, lambda
Grant
OAuth Proxy
Stars: ✭ 3,509 (+58383.33%)
Mutual labels:  aws, aws-lambda, lambda
Serverless Rust
⚡ 🦀 a serverless framework plugin for rustlang applications
Stars: ✭ 386 (+6333.33%)
Mutual labels:  aws, aws-lambda, lambda

AWS Lambda function for image resizing

This function will generate three (or more, or less) resized images for responsive websites: large, medium and small.

The functionality is based on the thumbnail generator described in http://docs.aws.amazon.com/lambda/latest/dg/walkthrough-s3-events-adminuser.html (this AWS documentation describes in detail how to setup the proper IAM user and roles).

Setup

Install npm packes async and gm (GraphicsMagick) in the root folder:

npm install async
npm install gm

Configure

Modify the code (resize_images.js) to change the configuration. If left unmodified, three sized images will be created.

// configuration as code - add, modify, remove array elements as desired
var imgVariants = [
  {
    "SIZE": "Large",
    "POSTFIX": "-l",
    "MAX_WIDTH": 1200,
    "MAX_HEIGHT": 1000,
    "SIZING_QUALITY": 70,
    "INTERLACE": "Line"
  },
  {
    "SIZE": "Medium",
    "POSTFIX": "-m",
    "MAX_WIDTH": 800,
    "MAX_HEIGHT": 800,
    "SIZING_QUALITY": 60,
    "INTERLACE": "Line"
  },
  {
    "SIZE": "Small",
    "POSTFIX": "-s",
    "MAX_WIDTH": 300,
    "MAX_HEIGHT": 400,
    "SIZING_QUALITY": 50,
    "INTERLACE": "Line"
  }
];
// The name of the destination S3 bucket is derived by
// adding this postfix to the name of the source S3 bucket:
var DST_BUCKET_POSTFIX = "-resized";

The source and destination AWS S3 buckets must exist.

Interface with AWS

The following assumes/requires the existence within your AWS account of:

  1. an "adminuser" user with administrative permission
  2. a "awsLambdaExecute" role with execute permission

Test whether lambda can be reached with the adminuser

aws lambda list-functions --profile adminuser

Create a zip file

Bundle both resize_images.js and the node_modules folder in a zip file

Upload the zip file

(run in the folder where the zip file is located):

aws lambda create-function \
--region us-west-2 \
--function-name resize_images \
--zip-file fileb://resize_images.zip \
--role arn:aws:iam::172166755826:role/awsLambdaExecute \
--handler resize_images.handler \
--runtime nodejs \
--profile adminuser \
--timeout 10 \
--memory-size 1024

Execute a test file input.json

Modify the input.json file: enter your S3 bucket name and your uploaded image name in the indicated locations. (The bucket must exist and you must have uploaded a jpg or png image for this test to succeed).

aws lambda invoke \
--invocation-type Event \
--function-name resize_images \
--region us-west-2 \
--payload file://input.json \
--profile adminuser \
outputfile.log

View execution logs

(assuming you are in region 'us-west-2')

https://us-west-2.console.aws.amazon.com/cloudwatch/home?region=us-west-2#logs:

Upload an updated zip file

In case any code changes are made, (re)zip the resize_images.js file and node_modules folder into "resize_images.zip" and re-upload.

(run in the folder where the zip file is located):

aws lambda update-function-code \
--region us-west-2 \
--function-name resize_images \
--zip-file fileb://resize_images.zip \
--profile adminuser

Execution through AWS console

Trigger the Lambda function in the source S3 bucket by adding a 'Put' Notification (send to your Lamda function) in the Events section of the bucket's Properties.

Once this is in place, uploading an image file to the source S3 bucket will automatically generate the resized images in the destination S3 bucket.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].