image processing lambda
This commit is contained in:
77
lambdas/imageProcessor/README.md
Normal file
77
lambdas/imageProcessor/README.md
Normal file
@@ -0,0 +1,77 @@
|
||||
# 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
|
||||
|
||||
1. User uploads image to `staging/{folder}/{uuid}.jpg` via presigned URL
|
||||
2. S3 triggers this Lambda
|
||||
3. Lambda extracts metadata and saves to `ImageMetadata` table
|
||||
4. Lambda strips EXIF data from image
|
||||
5. Lambda moves clean image to final location `{folder}/{uuid}.jpg`
|
||||
6. Lambda deletes staging file
|
||||
|
||||
## Local Development
|
||||
|
||||
### Install Dependencies
|
||||
|
||||
```bash
|
||||
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
|
||||
|
||||
```bash
|
||||
aws s3 cp source s3://bucket-name/staging/image-type/key --profile your-profile-name
|
||||
```
|
||||
|
||||
```bash
|
||||
npm run local -- staging/items/test-image.jpg my-bucket
|
||||
```
|
||||
|
||||
### Run Migration
|
||||
|
||||
```bash
|
||||
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](../../infrastructure/cdk/README.md) for deployment instructions.
|
||||
|
||||
```bash
|
||||
cd infrastructure/cdk
|
||||
npm run deploy:staging
|
||||
```
|
||||
Reference in New Issue
Block a user