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
- Import – load UIImage, normalize orientation, downscale if needed.
- Overlay config – text, size, color, position, opacity.
- Preview – render in SwiftUI Canvas (or CALayer fallback).
- Export – draw into Core Graphics context at target resolution.
Import behavior
- Honor EXIF rotation; user should never see a rotated preview.
- Large images (>12–15 MP) may be auto-downscaled for performance, not visibly in UI.
- Color space is converted to sRGB for consistent output.
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
- Preview uses SwiftUI drawing, not final export quality.
- Export uses Core Graphics for crisp text.
- All overlays are composited last to avoid any filtering from image resizing.
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
- Export must match preview positioning within 1–2 px.
- Keep UI controls minimal — avoid multi-step menus.
- Ensure fast export even on older devices.
Future considerations
- Multi-layer overlays (icons, QR, shapes).
- Batch export.
- Non-destructive presets.