Skip to content

Latest commit

 

History

History
 
 

crop

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

crop

Copy and crop images using Lambda.

Deploy with CloudFormation

Prerequisites: Node.js and AWS CLI installed

  • Create an AWS Account and IAM User with the AdministratorAccess AWS Managed Policy
  • Run aws configure to put store that user's credentials in ~/.aws/credentials
  • Create an S3 bucket for storing the Lambda code and store its name in a shell variable with:
    • export CODE_BUCKET=bucket
  • Create the S3 bucket for the cropped output, store its name in shell variable:
    • export DEST_BUCKET=bucket
  • Choose a name, but do NOT create the S3 bucket input comes from, store its name in shell variable:
    • export SOURCE_BUCKET=bucket
  • Choose the width in pixels, store it in shell variable:
    • export WIDTH=600
  • Choose the height in pixels, store it in shell variable:
    • export HEIGHT=400
  • Choose the x in pixels (number of pixels right from left edge to remove), store it in shell variable:
    • export X=50
  • Choose the y in pixels (number of pixels down from the top to remove), store it in shell variable:
    • export Y=50
  • Npm install:
    • npm install
  • Build:
    • npm run build
  • Upload package to S3, transform the CloudFormation template:
    • npm run package
  • Deploy to CloudFormation:
    • npm run deploy

Deploy from the AWS Serverless Application Repository

  • Create the destination bucket
  • Hit "Deploy" from the application page

Use

  • Images that you put into the source bucket will be transformed, then put into the destination bucket

Links

License

© 2017-2021 Evan Chiu. This project is available under the terms of the MIT license.