gmz.dev / docs / Watermarkd pipeline
Internal notes on image import, overlay, and export.
draft; refined as the app evolves.

Watermarkd pipeline

Watermarkd’s pipeline is built to be predictable: users import an image, configure overlays, and produce an export at a known size and quality. This doc captures the current steps and constraints.

Pipeline stages

  1. Import – load UIImage, normalize orientation, downscale if needed.
  2. Overlay config – text, size, color, position, opacity.
  3. Preview – render in SwiftUI Canvas (or CALayer fallback).
  4. Export – draw into Core Graphics context at target resolution.

Import behavior

Overlay model

Each overlay is a struct:

struct Overlay {
    var text: String
    var position: CGPoint   // normalized 0–1
    var scale: CGFloat      // relative to image width
    var color: UIColor
    var opacity: CGFloat
}

Positions remain device-agnostic by staying normalized.

Rendering

Export flow

// pseudocode outline
beginContext(size: targetSize, scale: 1.0)

draw(baseImage)

for overlay in overlays:
    drawText(overlay.text,
             at: overlay.position * targetSize,
             scale: overlay.scale,
             color: overlay.color.withAlpha(opacity))

return contextImage

Constraints

Future considerations