Skip to content

MerkleBros/generate-ascii-art-from-photographs

Repository files navigation

Demo (but only returns black and white images currently)

Generate color gradient ASCII art from photographs

Python3 tool for generating ASCII images locally in batches and a Serverless API for converting images into ASCII art. By default the batch ASCII art is generated with a randomly selected vapor wave color gradient. The API currently only returns black and white ascii images.

This is a modified version of a tutorial for generating ASCII art with color gradients. It has been extended for batch processing files and deployed to an API.

Input/output:

Input image of a camera Output image of an ascii camera with groovy vapor wave color gradient

Serverless API

The Serverless framework is a tool for easily deploying AWS Lambda functions and associated services like Amazon API Gateway, Cloudwatch, S3 buckets, etc.

Send a .jpg or .png file to the API and receive a black and white ascii image. Below input.jpg is sent to the API and output_two.png is received.

cd examples/ && curl -X POST --data-binary @input.jpg https://ovr5yyzvza.execute-api.us-east-1.amazonaws.com/dev/generate_ascii -o output_two.png

Batch conversion setup

Project uses pip-tools and virtual environment (venv) for managing dependencies.

Clone the repository and cd into the project, then run:

  • python3 -m venv venv && . venv/bin/activate && pip install pip-tools && pip-compile && pip-sync
  • Add photographs (.png, .jpg) to be converted to ASCII art into images directory.

Batch convert images into ASCII images

cd into src directory and run python3 python-generate-ascii.py.

ASCII art is generated in the results/ directory. A new directory is generated inside results/ based on parameter values and a randomly chosen vapor wave color scheme is applied. These parameters and color gradient can be changed in python-generate-ascii.py.

About

Python3 generate ascii art from photographs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published