# Emulsion

RAW image viewer and film simulation application with physically-based analog film rendering.

## Quick Install (macOS)

Install or update Emulsion with a single command:

```bash
curl -fsSL http://emulsion.zezic.ru/install.sh | bash
```

This downloads the latest version and installs it to `/Applications`. The app auto-updates itself, so you only need to run this once.

## Building

### Development Build
```bash
cargo build --release
cargo run --release
```

### macOS Bundle Distribution

The `bundle.sh` script creates a distributable macOS `.app` bundle:

```bash
# Install cargo-bundle (one-time)
cargo install cargo-bundle

# Create distribution bundle
./bundle.sh
```

This produces:
- `dist/Emulsion.app` - Standalone macOS application
- `Emulsion-v0.1.1.zip` - Distribution archive with app + launcher helper

The archive includes:
- **Emulsion.app** - The main application bundle
- **Emulsion.command** - Helper script to remove quarantine and launch the app

### Manual Bundle
```bash
cargo bundle --release
# Output: target/release/bundle/osx/rusty-emulsion.app
```

## Usage

**macOS**: Double-click `Emulsion.command` (first run) or `Emulsion.app` (subsequent runs)

**Command Line**: `cargo run --release`

## Deployment

### Build & Deploy Script

The `scripts/deploy.sh` script builds all platforms, generates manifest, and uploads to server:

```bash
# Install build dependencies (one-time)
cargo install cargo-bundle    # macOS app bundles
cargo install cargo-deb       # Linux DEB packages
cargo install cross           # Cross-compilation (requires Docker)
rustup target add x86_64-apple-darwin aarch64-apple-darwin

# Build all platforms
./scripts/deploy.sh

# Build and upload to server
./scripts/deploy.sh --upload

# Build only macOS (no cross-compilation)
./scripts/deploy.sh --macos-only
```

This produces:
- `dist/vX.X.X/` - All build artifacts
  - `Emulsion-vX.X.X-macos-arm64.tar.gz` - Apple Silicon
  - `Emulsion-vX.X.X-macos-x86_64.tar.gz` - Intel Mac
  - `Emulsion-vX.X.X-linux-x86_64.tar.gz` - Linux binary
  - `emulsion_X.X.X_amd64.deb` - Debian/Ubuntu package
  - `Emulsion-vX.X.X-windows-x86_64.zip` - Windows
  - `manifest.json` - Update manifest with SHA256 checksums
  - `index.html` - Download page

### Server Configuration

Edit `scripts/deploy.sh` to set your server details:
```bash
SERVER_HOST="emulsion.zezic.ru"
SERVER_USER="root"
SERVER_PATH="/var/www/emulsion"
BASE_URL="https://emulsion.zezic.ru"
```

### Server Structure
```
https://emulsion.zezic.ru/
├── index.html                  # Download page
├── install.sh                  # Quick install script
└── updates/
    ├── manifest.json           # Current version manifest
    ├── Emulsion-v0.3.6-macos-arm64.tar.gz
    ├── Emulsion-v0.3.6-macos-x86_64.tar.gz
    ├── Emulsion-v0.3.6-linux-x86_64.tar.gz
    ├── emulsion_0.3.6_amd64.deb
    └── Emulsion-v0.3.6-windows-x86_64.zip
```

## Auto-Updates

The app automatically checks for updates on startup. When a new version is available, a dialog appears offering to download and install it. This bypasses macOS quarantine since the app writes the update itself.

## Documentation

See `CLAUDE.md` for comprehensive technical documentation including:
- Architecture overview
- 7-stage film simulation pipeline
- Caching system
- Performance optimization
- Development notes

## TODO

- Static link with Windows libs
- Hide console on Windows
- Crop
- Zoom
- Ctrl + Z
- Gallery
    - Copy preset to other photos
    - Mass export
    - Photo categories
- Lens correction
- BM3D denoising
- Grain settings
