Video: https://www.facebook.com/share/v/17XgFxb2Ch/
Image to ASCII library
Converts an image to ASCII by mapping pixel brightness to characters that best resemble the local shape.
Steps:
1. Open PowerShell as administrator
2. Run your program there (not in Windows Terminal).
3. Right‑click the title bar of that PowerShell window.
4. Choose Properties (or Defaults if you want it to persist for all future windows).
5. Go to the Font tab.
6. In the Font list, select: Raster Fonts
7. Below that, select the size that shows as 8x12.
8. Click OK.
9. Resize the window horizontally so no lines wrap (wider is better).
10. Re-run:
.\Debug\amg.exe -w 220 "https://i.pinimg.com/736x/45/ba/bc/45babc999f84f62f329c50ff8fef55eb.jpg" > output\6.Raster_Fonts.txt
- Converts images to ASCII art.
- Supports different levels of detail and character sets.
- Multi-threaded processing for faster conversion.
Follow these steps to build and run the project in Visual Studio on Windows:
- Update Visual Studio to the latest version available to ensure required components are present.
- In Visual Studio, choose File > Open > Project/Solution and open
httptest.slnfrom the repository folder. - If Visual Studio prompts to install required components or workloads, follow the prompts to install them — Microsoft Visual Studio will suggest the necessary files.
- Open
main.cppin the solution explorer/editor. - Set the example image URL in
main.cpp. For example:
// main.cpp (example)
std::string setting_url = "https://i.pinimg.com/736x/45/ba/bc/45babc999f84f62f329c50ff8fef55eb.jpg";The example above uses a publicly available image URL. Replace it with any publicly accessible image you have the right to use.
- Build and run the executable without debugging using Ctrl+F5.
Notes:
- Ensure your machine has internet access when using an online image URL.
- Respect copyright and usage rights for images you process.
- If you prefer to use a local image file, modify the code accordingly to read from a local path instead of a URL.
- Open
httptest.slnin Visual Studio (Project/Solution) - Edit
main.cppto point to your image URL - Press Ctrl+F5 to build and run
These are the configurable settings in main.cpp (defaults shown):
setting_url(string): URL of the image to be converted.- Default in code:
"https://i.pinimg.com/736x/45/ba/bc/45babc999f84f62f329c50ff8fef55eb.jpg"
- Default in code:
setting_gamma(bool): Enable gamma correction for better contrast in darker regions. Default:true.setting_filter(bool): Enable pixel averaging/filtering for smoother sampling. Default:true.setting_multi(bool): Enable multi-region shape matching (uses a 3x3 grid per character). Default:true.setting_influence(bool): Use influence-based scoring weights for regions. Default:true.setting_simple(bool): Use a simple character set. Default:false.setting_random(bool): Use a full character set with random selection among closest matches. Default:false.setting_width(int): Width of the output ASCII art in characters. Default:79.
You can change these defaults in code or override them via command-line options.
The program accepts options followed by an image URL. Options are case-insensitive.
-gDisable gamma correction (turnssetting_gammaoff)- Example:
.\Debug\amg.exe -g "https://i.pinimg.com/736x/45/ba/bc/45babc999f84f62f329c50ff8fef55eb.jpg" > output\flag_g_disable_gamma.txt
- Example:
-fDisable pixel filtering (turnssetting_filteroff)- Example:
.\Debug\amg.exe -f "https://i.pinimg.com/736x/45/ba/bc/45babc999f84f62f329c50ff8fef55eb.jpg" > output\flag_f_disable_filter.txt
- Example:
-mDisable multi-region matching (turnssetting_multioff)- Example:
.\Debug\amg.exe -m "https://i.pinimg.com/736x/45/ba/bc/45babc999f84f62f329c50ff8fef55eb.jpg" > output\flag_m_no_multi.txt
- Example:
-iDisable influence-based scoring (turnssetting_influenceoff)- Example:
.\Debug\amg.exe -i "https://i.pinimg.com/736x/45/ba/bc/45babc999f84f62f329c50ff8fef55eb.jpg" > output\flag_i_no_influence.txt
- Example:
-sUse a simple character set (turnssetting_simpleon)- Example:
.\Debug\amg.exe -s "https://i.pinimg.com/736x/45/ba/bc/45babc999f84f62f329c50ff8fef55eb.jpg" > output\flag_s_simple.txt
- Example:
-rUse a full character set with randomness (turnssetting_randomon)- Example:
.\Debug\amg.exe -r "https://i.pinimg.com/736x/45/ba/bc/45babc999f84f62f329c50ff8fef55eb.jpg" > output\flag_r_random.txt
- Example:
-w [width]Set the output width, e.g.,-w 120- Example:
.\Debug\amg.exe -w 120 "https://i.pinimg.com/736x/45/ba/bc/45babc999f84f62f329c50ff8fef55eb.jpg" > output\flag_w_width120.txt
- Example:
Notes:
- The first non-flag argument is treated as the image URL.
-wmust be followed by a number (space separated).- If both
-sand-rare passed, simple mode (-s) takes precedence in practice.
From the project directory (where the built executable resides in Debug):
- High-detail (default behavior) with a wider width (120 columns):
.\Debug\amg.exe -w 120 "https://i.pinimg.com/736x/45/ba/bc/45babc999f84f62f329c50ff8fef55eb.jpg" > output\combo1_high_detail_width120.txt
- Fast & clean (simple charset, no gamma, medium width 100):
.\Debug\amg.exe -s -g -w 100 "https://i.pinimg.com/736x/45/ba/bc/45babc999f84f62f329c50ff8fef55eb.jpg" > output\combo2_simple_fast.txt
- Artistic random full set (random + no influence + width 100):
.\Debug\amg.exe -r -i -w 100 "https://i.pinimg.com/736x/45/ba/bc/45babc999f84f62f329c50ff8fef55eb.jpg" > output\combo3_random_artistic.txt
- see the ASCII in terminal WITHOUT saving to a file:
.\Debug\amg.exe -w 120 "https://i.pinimg.com/736x/45/ba/bc/45babc999f84f62f329c50ff8fef55eb.jpg"Tip: For best visual results in the terminal, set the console font to "Raster Fonts" 8x12.
