Skip to content

pvsssss/ascii-art-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ASCII Art Generator

A simple ASCII Art Generator written entirely in Python, designed to convert bitmap images into colorful ASCII representations directly in your terminal β€” no external libraries required.


Overview

This project takes a bitmap image as input, processes its raw pixel data, and transforms it into ASCII art while preserving brightness and color information. The entire pipeline is built using only Python’s standard library, making it lightweight, portable, and easy to run anywhere Python is available.


Features

  • Pure Python β€” uses only the Python standard library
  • Bitmap image parsing* to extract pixel-level data
  • Image downscaling using a box filter to reduce resolution
  • Grayscale conversion for accurate luminosity mapping
  • Colored ASCII output printed directly in the terminal

How It Works

  1. Parsing the bitmap image
    The program reads the bitmap image and extracts RGB pixel data.

  2. Downscaling image using Box Filter
    To reduce resolution, a box filter is applied over pixel regions, averaging values to preserve image structure.

  3. Converting image to grayscale
    Each pixel is converted to grayscale to accurately estimate luminosity.

  4. ASCII Mapping
    Pixel brightness values are mapped to ASCII characters based on intensity.

  5. Terminal Rendering
    The ASCII art is printed to the terminal using color codes to retain the original image’s feel.


Requirements

  • Ensure you have Python 3.10 installed
  • No external libraries or dependencies needed

Usage

  1. Clone the repository:
    gh repo clone pvsssss/ascii-art-generator
    cd ascii-art-generator
    
  2. Run the program:
python main.py
  1. Select a bitmap image when prompted The program will handle the rest automatically.

Configuration

If the output image appears too large, adjust the scaling factor:

  • Open main.py
  • Locate the SCALE variable and increase it's value

File Structure 🌲

β”œβ”€β”€ README.md
β”œβ”€β”€ samples/
β”‚   β”œβ”€β”€ sample1 in ascii.jpeg
β”‚   β”œβ”€β”€ sample1.bmp
β”‚   β”œβ”€β”€ sample2 in ascii.jpeg
β”‚   β”œβ”€β”€ sample2.bmp
β”‚   β”œβ”€β”€ sample3 in ascii.jpeg
β”‚   └── sample3.bmp
└── src/
    β”œβ”€β”€ ascii.py
    β”œβ”€β”€ image_processor.py
    β”œβ”€β”€ main.py
    β”œβ”€β”€ parser.py
    └── __pycache__/
        β”œβ”€β”€ ascii.cpython-311.pyc
        β”œβ”€β”€ ascii.cpython-313.pyc
        β”œβ”€β”€ image_processor.cpython-311.pyc
        β”œβ”€β”€ image_processor.cpython-313.pyc
        β”œβ”€β”€ main.cpython-313.pyc
        β”œβ”€β”€ parser.cpython-311.pyc
        └── parser.cpython-313.pyc

Notes

  • Works only with bitmap images
  • Terminal must support truecolor for colored output

Acknowledgments

This project was inspired and guided by learning resources from:


Contact

Feel free to reach out or connect with me:

Screenshots

Project Screenshot

Project Screenshot

Project Screenshot

About

A pure python implementation of ascii generator

Resources

Stars

Watchers

Forks

Contributors

Languages