A small frontend tool to upload an image and convert it to grayscale or black white.
- Purpose
- Installation
- Usage
- Function Description
- Tech Stack
Quick local image conversion in the browser without a server
git clone <your-repo-url>
cd image-tool
npm install
npm run devOpen http://localhost:5173
- Select an image
- Choose mode grayscale or black white
- Optionally adjust threshold for black white
- Save result from the canvas (right click → save as)
- For each pixel the luminance is calculated
- Formula
Y = 0.2126 * R + 0.7152 * G + 0.0722 * B - Channels R G B are set to Y
- Result is a grayscale image with realistic brightness perception
- For each pixel Y is calculated as above
- Compare with a threshold e.g. 128
- If Y is greater or equal → pixel set to white 255
- If Y is smaller → pixel set to black 0
- Result is a binary image with clear edges
- Image is loaded via file input and drawn to a canvas
- Pixels are read with
getImageDataand modified - Result is written back with
putImageData
- HTML Canvas API
- JavaScript or TypeScript
- Optional Vite for dev server
- Processing happens entirely in the browser
- No uploads to a server
- Large images may affect performance