A photo editor for the browser. Crop to a free or fixed shape, turn, flip and straighten; adjust the light and colour or pick a look; draw, point, box, write and hide parts of the picture. Every change can be undone, and Done hands back the picture as a file. Tools like this are usually sold as yearly licences; this one is MIT licensed, plain TypeScript, with no dependencies.
Install
- Clone
git clone https://github.com/drkxbt/photo- Install
npm install github:drkxbt/photo- Use
const blob = await editPhoto(file)
Features
- Crop free or to a shape, turn, flip, and straighten with the crop kept on the picture
- Brightness, contrast, saturation and warmth, and seven looks previewed on your own crop
- Pen, arrow, box, ellipse, text, and blocks that hide what should not be seen
- Every change undoable, a drag as one step, and a hold to compare with the original
- The same pixels in the preview, the file and every browser; runs under a strict Content Security Policy
How it works
- Quarter turns and flips are a 2×2 matrix, multiplied in the order they were made, so a flip after a turn mirrors what is on screen; the crop and every mark move with the picture.
- Straightening solves, for each corner of the crop, the largest scale about its middle that keeps it on the tilted picture, and takes the smallest.
- A crop drag that would leave the picture is cut back by a binary search to the last point that fits, and a move goes across, then down, so it slides along an edge.
- Adjustments are worked on the pixels with one lookup table for brightness and contrast, so the preview, the file and every browser agree; hiding averages blocks so nothing under them survives.
- Every edit is plain data, so it can be undone step by step, saved and opened again later.
Where it shows here
Only in its own demo for now: drk.vc has nothing for visitors to upload.
Screenshots
Stack
- TypeScript
- Canvas 2D
- Pointer Events
- Node test runner
Run it locally
git clone https://github.com/drkxbt/photocd photonpm installnpm run demo



