Files
rentall-app/lambdas/imageProcessor/README.md
2026-01-21 17:48:50 -05:00

67 lines
1.9 KiB
Markdown

# 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
```
### 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
```