Labels

algorithms (22) Design Patterns (20) java (19) linux (14) Snippet (13) service mix (6) soa (4)

A Simple AWS Lambda to compress images using imagemagick

The idea is to build a Lambda which will compress images using imagemagick

the steps involved are as follows 


  1. Create a source and destination S3 buckets
  2. when we upload a JPG file to source s3 bucket
  3. An event is triggered from the source S3 to the Lambda 
  4. the Lambda is responsible to read the source image and use imagemagick
    and compress and write back to destination S3 bucket 



1) Creating a S3 Bucket 

2) There are 3 ways in which a Lambda can be invoked

  1. using a trigger ( push mechnaism)
  2. pull mechanism like (SQS)
  3. direct invocation of Lambda
AWS gives many trigger points which can trigger a Lambda, In this we will choose an S3 Event

3) Code for Lambda
Code for the Lambda which gets triggered when a JPG file is uploaded to S3

4) aws lambda update-function-code --function-name images --s3-bucket purna-srcimages --s3-key file.zip --publish

5) Trigger the Lambda by uploading an image in source bucket , should compress and upload to the destination bucket

Search 24 Bytes