AlexandrAI AGENTS.md
agents-md

AlexandrAI Tools Image Watermark Agent Guide

Agent guide for text watermark opacity clamping, anchor positioning, and canvas PNG output.

AGENTS.md

Guidance for coding agents working on AlexandrAI Tools Image Watermark in the alexandrai-tools project.

Project overview

This guide covers src/tools/image-watermark. clampOpacity constrains opacity to zero through one. positionOffset returns top-left, top-right, bottom-left, bottom-right, or center anchor coordinates using a margin. Body.astro reads the source image, draws it to canvas, applies text styling, positions text with the helper, and downloads the watermarked image.

Primary source files

  • src/tools/image-watermark/index.ts defines meta, WatermarkPosition, clampOpacity, and positionOffset.
  • src/tools/image-watermark/index.test.ts covers opacity bounds and every supported position.
  • src/tools/image-watermark/Body.astro owns image loading, text input, position, opacity, font size, canvas drawing, PNG download, and clear state.
  • src/tools/image-watermark/i18n.ts owns localized labels.
  • src/lib/tools.ts registers the tool metadata.

Setup commands

npm install npm test npm run typecheck npm run build npm run dev

Change rules

  • Clamp opacity before drawing text.
  • Use the supplied margin for corner positions.
  • Use canvas midpoint for center position.
  • Keep supported positions aligned with WatermarkPosition.
  • Read image files locally with FileReader.
  • Download canvas output as PNG.
  • Do not upload source images or watermark text.

Testing

Test opacity boundaries, all positions, custom margins, text drawing alignment, empty text behavior, font size input, PNG download, clear state, and privacy copy.

PR checklist

  • npm test passes for image-watermark.
  • Pure helper behavior and browser UI behavior are aligned.
  • Generated CSS, Markdown, JSON, or image output remains browser-local.
  • Invalid input, copy behavior, and privacy expectations are covered.