Feature: Stage 4 - Profile Calculation & colprof Integration #7

Closed
opened 2026-08-21 10:29:34 +01:00 by gronod · 0 comments
Owner

Description

Implement the Stage 4 Profile Generation step. After .ti3 measurement data is obtained, the user configures profile quality and metadata, then the Rust backend spawns colprof as a long-running background process to compute the ICC profile.

Toolchain Context

  • Backend: Rust (Tauri 2) — spawns colprof via ProcessManager; process runs in tokio async task without blocking the UI thread
  • Frontend: Vanilla JS with indeterminate progress spinner

Implementation Plan

Backend (Rust)

  1. New Tauri command commands::run_colprof(app, state, config):
    • Accept ColprofConfig struct: { quality: String, algorithm: String, description: String, copyright: Option<String>, source_gamut: Option<String>, basename: String }
    • Build args: ["-v", "-q", <quality>, "-a", <algo>, "-D", <desc>, <basename>]
    • Optionally append -C <copyright> and -S <source_gamut>.icm
    • Spawn via ProcessManager
  2. Progress heuristics: Parse verbose (-v) stdout for stage markers (e.g., "Creating", "Gamut mapping"). Emit coarse-grained process:progress events with estimated stage labels: { stage: "gamut_mapping" | "fitting" | "writing", percent: <estimated> }.
  3. Completion verification: After exit code 0, verify .icc / .icm file exists. Emit process:complete with file path and size.

Frontend (JavaScript)

  1. Stage 4 panel (#stage-4):
    • Quality dropdown: Low / Medium / High / Ultra with time estimates
    • Profile Description text input (mandatory)
    • Copyright text input (optional)
    • Algorithm selector (cLUT default, hidden behind "Advanced" toggle)
    • "Create Profile" button invokes run_colprof
  2. Progress display:
    • Indeterminate spinner by default
    • When process:progress events arrive, show stage label (e.g., "Gamut mapping…")
    • Collapsible raw log panel showing colprof stdout
  3. Completion: Display success card with ICC file path, file size, and "Verify Profile" button to advance to Stage 5.

New/Modified Files

  • [MODIFY] src-tauri/src/commands.rs — add run_colprof command, ColprofConfig struct
  • [MODIFY] src-tauri/src/events.rs — add emit_progress event type
  • [MODIFY] src/index.html — expand Stage 4 panel
  • [NEW] src/js/colprof.js — Stage 4 frontend logic
  • [MODIFY] src/styles/main.css — spinner and progress stage styles

Acceptance Criteria

  • User can configure quality, description, and algorithm
  • colprof spawns and runs without freezing the UI
  • Verbose stdout displayed in collapsible log panel
  • Stage progress labels shown when available
  • ICC profile file produced and verified on exit
  • Ultra quality profiles (~30+ minutes) handled gracefully with ongoing feedback

References

### Description Implement the Stage 4 Profile Generation step. After `.ti3` measurement data is obtained, the user configures profile quality and metadata, then the Rust backend spawns `colprof` as a long-running background process to compute the ICC profile. ### Toolchain Context - **Backend**: Rust (Tauri 2) — spawns `colprof` via `ProcessManager`; process runs in tokio async task without blocking the UI thread - **Frontend**: Vanilla JS with indeterminate progress spinner ### Implementation Plan #### Backend (Rust) 1. **New Tauri command** `commands::run_colprof(app, state, config)`: - Accept `ColprofConfig` struct: `{ quality: String, algorithm: String, description: String, copyright: Option<String>, source_gamut: Option<String>, basename: String }` - Build args: `["-v", "-q", <quality>, "-a", <algo>, "-D", <desc>, <basename>]` - Optionally append `-C <copyright>` and `-S <source_gamut>.icm` - Spawn via `ProcessManager` 2. **Progress heuristics**: Parse verbose (`-v`) stdout for stage markers (e.g., "Creating", "Gamut mapping"). Emit coarse-grained `process:progress` events with estimated stage labels: `{ stage: "gamut_mapping" | "fitting" | "writing", percent: <estimated> }`. 3. **Completion verification**: After exit code 0, verify `.icc` / `.icm` file exists. Emit `process:complete` with file path and size. #### Frontend (JavaScript) 1. **Stage 4 panel** (`#stage-4`): - Quality dropdown: Low / Medium / High / Ultra with time estimates - Profile Description text input (mandatory) - Copyright text input (optional) - Algorithm selector (cLUT default, hidden behind "Advanced" toggle) - "Create Profile" button invokes `run_colprof` 2. **Progress display**: - Indeterminate spinner by default - When `process:progress` events arrive, show stage label (e.g., "Gamut mapping…") - Collapsible raw log panel showing colprof stdout 3. **Completion**: Display success card with ICC file path, file size, and "Verify Profile" button to advance to Stage 5. #### New/Modified Files - `[MODIFY]` `src-tauri/src/commands.rs` — add `run_colprof` command, `ColprofConfig` struct - `[MODIFY]` `src-tauri/src/events.rs` — add `emit_progress` event type - `[MODIFY]` `src/index.html` — expand Stage 4 panel - `[NEW]` `src/js/colprof.js` — Stage 4 frontend logic - `[MODIFY]` `src/styles/main.css` — spinner and progress stage styles ### Acceptance Criteria - [ ] User can configure quality, description, and algorithm - [ ] colprof spawns and runs without freezing the UI - [ ] Verbose stdout displayed in collapsible log panel - [ ] Stage progress labels shown when available - [ ] ICC profile file produced and verified on exit - [ ] Ultra quality profiles (~30+ minutes) handled gracefully with ongoing feedback ### References - [README.md §7 — Stage 4: Profile Calculation](README.md#7-stage-4-profile-calculation-colprof) - Upstream ArgyllCMS `colprof`: [gronod/argyllcms](https://git.i3omb.com/gronod/argyllcms)
gronod added this to the Milestone 4: Profiling & Verification Engine milestone 2026-08-21 10:29:34 +01:00
Sign in to join this conversation.