GithubHelp home page GithubHelp logo

stephengodderidge / aws-lambda-image-compressor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dariospadoni/aws-lambda-image-compressor

0.0 1.0 0.0 21 KB

AWS lambda function to compress and resize images

License: GNU General Public License v3.0

JavaScript 100.00%

aws-lambda-image-compressor's Introduction

aws-lambda-image-compressor

AWS lambda function to compress and resize images

This is a Lambda Function which resizes/reduces images automatically. When an image is put on some AWS S3 bucket, this function will resize/reduce it and save it into a new bucket.

I found 2 projects which doing the same but I could not make them properly work. With the first I could not compress PNG images; with the second I had issues with packaging and module dependency on S3.

I then decided to write my simple function and some gulp task to quickly deploy it into AWS. This article was a great reference.

Flow

The function should be invoked by a S3 trigger when a new image is uploaded to some S3 bucket. Once invoked, the function compresses and resizes (if needed) the original image and save those copies into another bucket. You can easily configure the widths of the resized image and their destination bucket/subfolder.

  • PNG images are saved as JPG
  • if an image is smaller than a desired resizing, it is copied without being resized into destination bucket

Requirements

  • node.js (AWS Lambda working version is 4.3.2)

Usage

  • edit lambda-config.js file and assign name, description, memory size, timeout of your lambda function.
  • edit .env file with your AWS access data
  • npm install
  • gulp deploy

Update Runtime

In case you need to update your runtime environment, you can run the following command:

aws lambda update-function-configuration --function-name <function name as in lambda-config.js> --runtime nodejs4.3

Todo

  • some code optimization
  • tests
  • read images compression/resizing configuration from an external json file

aws-lambda-image-compressor's People

Contributors

dariospadoni avatar pizzapete avatar weijtmans avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.