Lambda Image Manager is AWS Lambda function that store, get, manipulate images in AWS S3.
If you are using Cloudinary or Imgix like service just for resizing or basic image manipulation, maybe you don't need them anymore.
If you aren't used to Serverless or AWS Lambda, I highly recommend that read Serverless docs first.
Remember! AWS provides free tier amount, but this whole service is not FREE.
- Add DynamoDB logic.
- Make empty AWS S3 bucket for image file store.
- Make and set AWS DynamoDB for cache.(Not supported yet)
git clone https://github.com/TylorShin/lambda-image-manager.git
cd lambda-image-manager
npm install
And set production environment. (If you want to stage or other)
# /env/prod.yml
S3_BUCKET_NAME: lambdaImage
S3_DEST_PREFIX: images/original
The S3 folder structure should be like below.
# lambdaImage Bucket
/root
/images
/original
Then if you ready to deploy Serverless project, just run
npm run deploy:prod
IMPORTANT
(this image is actually from my own service by using this repository)
You should set lambda-image-manager's API Gateway's binary support option.
At API Gateway setting page, set binary option allow header to "image/*". Then, Deploy API Gateway once again in console dashboard.
WIP
- A browser try to presentation tag with src property heading our API gateway that trigger lambda function.
- Lambda get request with image id, image file name, image manipulation options.
- Trying to find pre-manipulated result from AWS DynamoDB as cache. If the target image is already manipulated with same option, then read that image's address from DynamoDB and return redirect response to that address.
- If there is no cache, manipulate target image with given options.
- Change the image to Buffer with BASE64 encode.
- After that, store the result to S3 and record result address to DynamoDB with manipulation options.
- return manipulated target image to user.
- Serverless - The web framework used
WIP
WIP