Skip to content

feat(watermark): auto-select dark/light logo variant based on background #3

Description

@peb-peb

Summary

The watermarking pipeline always stamps the white logo, regardless of the image it's placed on. On light or white-background images the watermark is nearly invisible. We already ship both variants in src/assets/:

  • OSCode-Logo-White.svg
  • OSCode-Logo-Black.svg

…but only the white one is used. Add dark/light variant selection so the watermark stays legible on any background.

Current behaviour

src/lib/server/watermark.ts hardcodes the asset:

const WATERMARK_PATH = path.join(process.cwd(), 'src/assets/OSCode-Logo-White.svg');

Proposed approach

  • Sample the average luminance of the region where the watermark will be placed (e.g. crop that corner, compute mean brightness via sharp's .stats()).
  • Pick black logo on light backgrounds and white logo on dark backgrounds (contrast-based auto-selection).
  • Load/cache both variants (extend the single-buffer cache in loadWatermark).
  • (Optional) allow an explicit override (light / dark / auto) via request param — pairs naturally with #logo-placement-options.

Acceptance criteria

  • Watermark is clearly visible on both dark and light images.
  • No regression in output size/quality or performance.

Related

  • Complements the logo placement options issue — both touch watermark.ts and could share a small "watermark options" config.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    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