Skip to content

Unified-transform convert (one-pass crop+downsample+codec+container) + revive transcode #6

Description

@cornish

Make convert a single-pass transform pipeline that composes container change, codec change, crop, and downsample in one decode→transform→encode pass, while keeping crop / downsample / transcode as simple single-axis convenience aliases. Chaining the verbs (crop | downsample | transcode) re-encodes the pixels once per stage — N× time and N× generational quality loss — whereas the unified path decodes the cropped region once and rebuilds the pyramid once.

Designed and planned, not yet executed.

Docs (on main)

Model

One axis per verb; convert is the union (ImageMagick-style — also covers the plain container case):

Axis Single-op alias Flag(s) Status
space crop --rect X,Y,W,H exists
resolution downsample --factor / --target-mag exists
codec transcode (revive) --codec / --quality Plan 2
container + all convert --to + the above Plan 1+2
orientation rotate / flip --rotate / --flip deferred (slotted)
pyramid structure retile --tile-size / --level-ratio / --levels deferred (slotted)

Plan 1 — engine convergence + convert --rect (11 tasks)

  • downscale.MaterializeWorkingL0 (crop∘downsample front-end).
  • Converge the duplicate downsampleTo* (convert_factor.go) + cropTo* (crop_formats.go) per-format emitters into one shared transformTo* family fed by transformParams.
  • Wire convert --to X --rect … [--factor N] so crop + downsample + container fuse in one pass. crop / downsample unchanged.
  • Behavior-preserving; guarded by each format's existing crop+downsample tests + a dciodvfy gate for DICOM ImageType.

Plan 2 — surface + safety rails (separate spec-driven plan, after Plan 1)

  • transcode alias (codec axis); --to defaults to source format (format-preserving default); arbitrary --codec on the transform path.
  • Three-tier conformance validation (impossible = hard error · non-conformant = error + --allow-nonconformant + warn · valid-but-limited = warn) with a single codec×container capability table — designed to consume an upstream opentile-go validator if one lands.
  • Lossless-regime generalization (auto-passthrough classifier); --jobs/--workers reconciliation.

Deferred (slots reserved, separate future specs)

Orientation (rotate/flip — net-new raster rotation), pyramid structure (--tile-size/--level-ratio/--levels, retile), de-identification (label/PHI strip during convert), metadata policy (ICC/vendor preserve/strip), bit-depth/colorspace, multi-dim (Z/C) selection.

Execution

Execute Plan 1 task-by-task via subagent-driven-development (fresh subagent per task + two-stage review; controller runs the heavy integration/dciodvfy steps). Then brainstorm→spec→plan Plan 2 on the converged engine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions