Production-ready Pillow layers for AWS Lambda supporting Python 3.9 through 3.13.
Download the latest layer for your Python version:
| Python Version | Download Link | Layer ARN |
|---|---|---|
| 3.9 | Download | arn:aws:lambda:region:account:layer:pillow-python39:1 |
| 3.10 | Download | arn:aws:lambda:region:account:layer:pillow-python310:1 |
| 3.11 | Download | arn:aws:lambda:region:account:layer:pillow-python311:1 |
| 3.12 | Download | arn:aws:lambda:region:account:layer:pillow-python312:1 |
| 3.13 | Download | arn:aws:lambda:region:account:layer:pillow-python313:1 |
# Upload layer to AWS Lambda
aws lambda publish-layer-version \
--layer-name pillow-python313 \
--description "Pillow layer for Python 3.13" \
--zip-file fileb://python3.13-v1.zip \
--compatible-runtimes python3.13 \
--compatible-architectures x86_64import json
from PIL import Image
import io
def lambda_handler(event, context):
# Pillow is now available!
try:
# Process image from S3
if 'Records' in event:
bucket = event['Records'][0]['s3']['bucket']['name']
key = event['Records'][0]['s3']['object']['key']
# Your image processing code here
img = Image.new('RGB', (100, 100), color='red')
return {
'statusCode': 200,
'body': json.dumps('Image processed successfully!')
}
except Exception as e:
return {
'statusCode': 500,
'body': json.dumps(f'Error: {str(e)}')
}| Feature | Value |
|---|---|
| Pillow Version | 10.4.0 |
| Layer Size | ~3.6MB (compressed) |
| Architecture | x86_64 |
| Supported Formats | JPEG, PNG, GIF, WEBP |
| Python Versions | 3.9, 3.10, 3.11, 3.12, 3.13 |
| Memory Usage | ~171MB (uncompressed) |
- Python 3.9+ installed
- System dependencies for Pillow compilation
# Clone the repository
git clone https://github.com/serverlessia/lambda-pillow-layer.git
cd lambda-pillow-layer
# Build layers for all Python versions
cd aws-lambda-pillow-layer
./scripts/build-multi-version.sh
# Test all layers
./scripts/test-multi-version.sh# Build for specific Python version (defaults to 3.13)
./scripts/build.shOpen in VS Code DevContainer for automatic multi-version building and testing:
- Open project in VS Code
- Use "Reopen in Container" command
- Layers will be built and tested automatically
- Image Creation: 4 images in 0.01s
- Image Processing: 4 images in 0.15s
- Format Conversion: 3 images to 3 formats in 0.15s
- Memory Cleanup: Excellent (0MB increase)
- Large Images: 4000x4000 processed in 0.38s
| Component | Status | Notes |
|---|---|---|
| Python 3.9 | ✅ Working | Full Pillow support |
| Python 3.10 | ✅ Working | Full Pillow support |
| Python 3.11 | ✅ Working | Full Pillow support |
| Python 3.12 | ✅ Working | Full Pillow support |
| Python 3.13 | ✅ Working | Full Pillow support |
| CI/CD | ✅ Active | Automated builds and releases |
| DevContainer | ✅ Ready | Multi-version support |
MIT License - see LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Test with
./scripts/test-multi-version.sh - Submit a pull request
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Wiki