GithubHelp home page GithubHelp logo

twopointone / image-resize-lambda Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 3.0 14.36 MB

Image Resizing AWS Lambda using Smartcrop.js

License: MIT License

Makefile 2.59% JavaScript 95.18% Dockerfile 2.23%
aws-lambda smartcrop smartcrop-sharp sharp image-resize image-crop

image-resize-lambda's Introduction

image-resize-lambda

Image Resizing AWS Lambda using Smartcrop.js

Setup Instructions

Setup node

  1. Install NVM

     curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
    
  2. Open new terminal window (To source the new scripts added in .bash_profile) and cd to the root of the project and run

     nvm install    # this will install the required node version
    
  3. Install node modules

     npm install
    

Setup env variables.

The project should directly run with default values for the local environment if you need to setup the specific environment variables create a copy of .env.sample with name .env and replace the values.

Start running project

  1. Move to the main directory and make sure correct node version is active.

     nvm use
    
  2. Start the server

     node server.js
    
  3. Add one of the images in the input folder with a name/directory 'abc/xyz.jpeg'

  4. This can be cropped and accessed using the url.

     images - manipulation
    
     localhost:3000/images/size:200x200/extend:b/blur:5.2/type:crop/xyz.jpeg
    
     localhost:<port>/images/size:<Width>x<Height>/extend:<h/w/b>(optional)/blur:<0.3 - 1000>(optional)/auto_rotate:<true/false>(optional)/type:<crop/cover/blurredframe>/<path>
    
     fetching raw files
    
     localhost:3000/raw/xyz.jpeg
    
     localhost:<port>/raw/<path>
    
  5. Url dissection parameters

     1. processor - image / raw for now
     Processor parameter defines the way you want to process my file.
    
     2. size - <Width>x<Height>
     Size parameter is the required dimensions with which you want to process my file. You can also input one of the two ie width eg. (100x) or height eg. (x100).
    
     3. extend - (h/w/b)
     Extend parameter defines the dimensions in which you want to extend your image ie. h for height, w for width and b for base. Its an optional parameter and if not provided the image would not be enlarged above its natural size.
    
     4. blur - number between 0.3 - 1000
     Blur parameter defines the blur radius with which you want to blur your image. Its also an optional parameter.
    
     5. auto_rotate - (true/false)
     auto_rotate parameter defines whether you want to apply auto rotate the image. Its default value is true.
    
     6. type - crop/cover/blurredframe
     Type parameter defines the type of image processing we want to do with our image. This is a required parameter.
    
     7. path
     The path of your file.
    

image-resize-lambda's People

Contributors

chaudhary avatar harshal27 avatar rubish avatar vikalpj avatar

Stargazers

 avatar

Watchers

 avatar  avatar

image-resize-lambda's Issues

Add Following processing to work for images

  • /image/WIDTHxHEIGHT:crop/key - only crops by resizing the image and keeping portion as center gravity.
  • /image/WIDTHxHEIGHT:cover/key - resizes the image without cropping anything, one of the dimensions may be smaller than provided.
  • /image/WIDTHxHEIGHT:smart/key - do not crop more than necessary (user minimal option in smartcrop) and select area to keep based on interestingness.

Lets try to move width and height calculations before actually calling the image processing function

In https://github.com/PrimeDigitalGlobal/image-resize-lambda/pull/14/files#diff-d06c639d4804f2f7ec74ed3beb48dcd7R111 We are doing processing of width & height at 2 places

  1. Inside the image processing function itself and
  2. In validateImageCropSize (https://github.com/PrimeDigitalGlobal/image-resize-lambda/pull/14/files#diff-d06c639d4804f2f7ec74ed3beb48dcd7R53)

Lets try to move every thing at one place ideally when validateImageCropSize is called.

handle errors gracefully.

When the handler function tries to find the width and size and the regex is not matched a error is raised at the node server and is not handled

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.