AlexandrAI AGENTS.md
agents-md

AlexandrAI Tools Image Rotate Flip Agent Guide

Agent guide for quarter-turn image rotation, dimension swapping, and canvas flip transforms.

AGENTS.md

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

Project overview

This guide covers src/tools/image-rotate-flip. rotatedDims swaps width and height for 90 and 270 degree rotations and keeps dimensions for zero and 180. Body.astro keeps a working canvas, copies current pixels to a temporary canvas before transforms, rotates around canvas center, flips with translate and scale, and downloads rotated.png.

Primary source files

  • src/tools/image-rotate-flip/index.ts defines meta, RotateDeg, and rotatedDims.
  • src/tools/image-rotate-flip/index.test.ts covers 90, 270, 180, zero, and square image behavior.
  • src/tools/image-rotate-flip/Body.astro owns image loading, rotation buttons, horizontal and vertical flip buttons, transform canvas logic, PNG download, and clear state.
  • src/tools/image-rotate-flip/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

  • Limit rotation choices to zero, 90, 180, and 270 degrees.
  • Swap output canvas dimensions only for 90 and 270 degree rotations.
  • Copy the current canvas into a temporary canvas before applying a rotation.
  • Rotate around the output canvas center.
  • Use translate plus scale for horizontal and vertical flips.
  • Restore canvas context after flip transforms.
  • Keep download output as PNG unless format controls are added.

Testing

Test rotatedDims for rectangular and square inputs, sequential rotations, horizontal flip, vertical flip, flip after rotation, rotation after flip, canvas dimensions, PNG download, and clear-state reset.

PR checklist

  • npm test passes for image-rotate-flip.
  • Canvas processing stays browser-local and deterministic enough for tests.
  • Pure helper behavior, UI controls, and i18n labels stay aligned.
  • Download format, filename, and reset behavior are covered.