Featured image of post Converting Image to ASCII

Converting Image to ASCII

Using p2ascii tool

Simple local guide on how to install a program to convert images to ASCII art.

You can find all instructions here.

Github Repository: 🔗 https://github.com/Hugana/p2ascii

Installation

On my machine, Python did not allow installing packages normally, so I had to create a virtual environment:

Do not forget to change your username (YourUsername) in these commands

1
python -m venv /home/YourUsername/yourenv

Then I activated it:

1
source /home/YourUsername/yourenv/bin/activate

And installed dependencies via pip:

1
pip install opencv-python numpy

Now, just navigate to the folder where your image is and run these two commands:

1
2
source /home/YourUsername/yourenv/bin/activate
/usr/bin/p2ascii cc2cimage name_of_your_image.jpg auto

Examples

Original cc2cimage  auto

Original cc2cimage  auto

Original Treshold 10 Treshold 120 Treshold 250

Usage taken from Github

I know it’s a bit lazy, but I want to save this here for myself.

Simple Conversion (No Edge Detection)

sc2image <img> [--transparent] Convert image to ASCII image
sc2text <img> Convert image to ASCII text (stdout)
sc2cimage <img> [--transparent] Colored ASCII image
sc2ctext <img> Colored ASCII text (stdout)

Complex Conversion (With Edge Detection)

cc2image <img> <thresh> [--transparent] ASCII image using edge orientation
cc2text <img> <thresh> ASCII text with edge symbols (stdout)
cc2cimage <img> <thresh> [--transparent] Colored ASCII image with edge awareness
cc2ctext <img> <thresh> Colored ASCII text with edge symbols

Threshold Parameter ()

Used in complex conversion to control edge sensitivity based on gradient magnitude.

auto: Automatically computes threshold as the 90th percentile of non-zero magnitudes:
0–255: Manual threshold.
    Higher = fewer edges (only strong ones)
    Lower = more edges (fine details)

Transparency Mode (–transparent)

When included, the output ASCII image will have a transparent background, displaying only the characters. This option is applicable to image output commands: sc2image, sc2cimage, cc2image, and cc2cimage.

Life is a choice: reboot or be root


Built with Hugo
Theme Stack designed by Jimmy