2.5 KiB
2.5 KiB
Image Processor Lambda
Processes uploaded images by extracting metadata (EXIF, GPS, camera info) and stripping it before storing publicly. Triggered by S3 uploads to the staging/ prefix.
How It Works
- User uploads image to
staging/{folder}/{uuid}.jpgvia presigned URL - S3 triggers this Lambda
- Lambda extracts metadata and saves to
ImageMetadatatable - Lambda strips EXIF data from image
- Lambda moves clean image to final location
{folder}/{uuid}.jpg - Lambda deletes staging file
Local Development
Install Dependencies
cd lambdas/shared && npm install
cd ../imageProcessor && npm install
Set Up Environment
Environment Variables
| Variable | Description | Example |
|---|---|---|
DATABASE_URL |
PostgreSQL connection string | postgresql://user:pass@localhost:5432/db-name |
S3_BUCKET |
S3 bucket name | bucket-name |
AWS_REGION |
AWS region | us-east-1 |
LOG_LEVEL |
Logging level | debug, info, warn, error |
Run Locally
aws s3 cp source s3://bucket-name/staging/image-type/key --profile your-profile-name
npm run local -- staging/items/test-image.jpg my-bucket
Run Migration
cd backend
npx sequelize-cli db:migrate
Supported Image Types
- JPEG (
.jpg,.jpeg) - PNG (
.png) - GIF (
.gif) - preserves animation - WebP (
.webp)
Metadata Extracted
| Field | Description |
|---|---|
latitude, longitude |
GPS coordinates (stripped from public image) |
cameraMake, cameraModel |
Camera manufacturer and model |
cameraSoftware |
Software used to create image |
dateTaken |
Original capture date |
width, height |
Image dimensions |
orientation |
EXIF orientation flag |
fileSize |
File size in bytes |
Deployment
See infrastructure/cdk/README.md for deployment instructions.
cd infrastructure/cdk
npm run deploy:staging