February 26, 2024

(Almost) free image processing with imgproxy and AWS Lambda

  • tutorial
Multiple space shuttles flying up above clouds

What is AWS Lambda?

Prerequisites

Deploying imgproxy on AWS Lambda

Step 1: Push the imgproxy Docker image to the ECR repository

# Replace region and account ID (123456789) with your actual region and account ID
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 123456789.dkr.ecr.us-east-1.amazonaws.com
docker pull darthsim/imgproxy:latest-arm64
# Replace region and account ID (123456789) with your actual region and account ID
docker tag darthsim/imgproxy:latest-arm64 123456789.dkr.ecr.us-east-1.amazonaws.com/imgproxy:latest
docker push 123456789.dkr.ecr.us-east-1.amazonaws.com/imgproxy:latest

Step 2: Deploy imgproxy on AWS Lambda

Testing the setup

https://<your-function-url>/unsafe/rs:fill:500:400/g:sm/f:avif/plain/https://assets.imgproxy.net/sample-corgi.jpg
Photo of a corgi resized with imgproxy
The result of resizing

The cost of imgproxy on AWS Lambda

Conclusion

Resizeable image

Start your free trial today: