squadrun / lambda-image-compression

18 stars 9 forks source link

Image Compression on AWS Lambda using Python 3.6

Highlights

  1. Pillow==4.1.1 compiled to be usable with AWS Lambda
  2. Python scripts for the actual compression

How to use

  1. Understand what is Lambda and how to use it: Getting Started with AWS Lambda. Also check out how to work with Python on AWS Lambda: Packaging for Lambda
  2. Go through the architecture in the accompanying blog: Leveraging AWS Lambda for Image Compression at scale
  3. Deploy orchestrator.py and image_compress.py using AWS Lambda.
  4. Invoke the lambda for orchestrator with a payload like:
    {
    "key_urls_map": {
            "image1.jpg": "https://media.licdn.com/media/p/8/005/05b/1fb/0cf50ca.png",
            "image2.jpg": "https://media.licdn.com/media/p/8/005/05b/1fb/0cf50ca.png"
        },
    "quality": 90,
    "bucket_name": "compression-test-bucket"
    }
  5. Check your S3 bucket for the compressed images^