Repository navigation
How It Works
Tymur Shashok edited this page Oct 5, 2026
·
1 revision
- Load: the image is loaded with OpenCV (JPG, PNG, BMP and other formats OpenCV supports).
- Resize: the image is resized to 200 × 200 pixels.
- Read pixels: for every pixel the R, G and B values are read.
- Compute brightness: a value from 0 to 255 is calculated with the standard luminance formula.
-
Map to a character: the brightness is mapped to an index in the active character set, from dark characters (
@,#) to light ones (., space). -
Output: the character is printed to the console (colored with the pixel's RGB value in RGB mode) and written to
image.txt(always without color).
brightness = 0.299 · R + 0.587 · G + 0.114 · B
The weights reflect how the human eye perceives each channel: green contributes the most, blue the least.
| Mode | Characters |
|---|---|
smallSymb |
@#*+=-:. |
mediumSymb |
@#W$9876543210?!;:=-,._ (default)
|
largeSymb |
@$#WmaOzAdzcfvxrjft/|()1{}[]?-_+~<>i!lI;:,"^'. ` |
A larger set gives more brightness levels, so more detail and smoother gradients. A smaller set gives a cleaner, higher-contrast look.
- BlackWhite: plain characters, no escape codes.
- RGB: each character is wrapped in a 24-bit ANSI escape sequence using the pixel's color. Requires a terminal that supports true color.
The saved image.txt is always plain text, regardless of the color mode.
Image2ASCII · MIT License · Repository