# 14 — Photo Enhancement

## Context
Fogbreak adds AI photo enhancement — sky replacement, HDR, color correction, perspective fix. None of the 6 replaced platforms offer this natively.

## What to Build

### 1. Enhancement API
Create `app/api/photos.php`:
```
POST /api/photos.php?action=enhance            # Submit for enhancement
POST /api/photos.php?action=sky_replace         # Replace sky
POST /api/photos.php?action=hdr                 # HDR processing
POST /api/photos.php?action=color_correct       # Color correction
POST /api/photos.php?action=perspective_fix     # Straighten vertical lines
POST /api/photos.php?action=batch_enhance       # Enhance all listing photos
GET  /api/photos.php?action=status&job_id=X     # Check status
GET  /api/photos.php?action=result&job_id=X     # Get enhanced image
```

### 2. Provider Integration
Primary: **Autoenhance.ai** (web-based, API available)
Fallback: **Snapflys** for RAW-to-HDR processing

Features:
- Sky replacement (gray sky → blue sky/sunset)
- HDR tone mapping (bracket blending)
- Exposure balancing (bright windows + dark interiors)
- Color vibrancy enhancement
- Vertical line correction (lens distortion fix)
- Lawn greening
- Twilight conversion (daytime exterior → dusk shot)

### 3. Batch Processing
- Select all photos for a listing
- Apply consistent enhancement preset
- Process queue with progress tracking
- Before/after comparison for each

### 4. Enhancement Presets
- **Standard**: Color correct + exposure balance
- **Premium**: Standard + sky replace + HDR
- **Luxury**: Premium + twilight + lawn green
- **Custom**: Agent picks individual enhancements

### 5. Integration Points
- Enhanced photos replace originals in listing (or stored alongside)
- Feed into virtual staging (instruction 12)
- Feed into video generation (instruction 13)
- Feed into social posts (instruction 11)
- Feed into property alerts (instruction 09)

## Acceptance Criteria
- [ ] Sky replacement API integration
- [ ] HDR and color correction processing
- [ ] Perspective/distortion fix
- [ ] Batch processing for full listings
- [ ] Enhancement presets (standard, premium, luxury)
- [ ] Before/after comparison
- [ ] Enhanced photos flow into all downstream features
