Inspiration

We decided it'd be rather cool to generate ASCII art from an image - especially the full-color ones. Later on, while working, we realized the potential to develop this for not only still images but animated GIFs as well.

What it does

Our project converts an image to grayscale, then divides the image into uniform blocks of pixels with a ratio of 2:3. Each block has its grayscale color value averaged, which we then mapped to a character (@, %, #, x, +, =, :, -, ., and space). The characters were mapped according to the amount of space they occupied; for example, the @ symbol takes up the most space and is thus assigned to the darkest grayscale colors, while the space character is for the opposite end of the spectrum. For GIFs, the generator first splits them into its component frames and does the above process for each. Afterwards, the resulting ASCII art is formatted as HTML and CSS and displayed in a monospace font in a JavaFX window; for a GIF, the art is constantly updated frame to frame to achieve an animation.

How we built it

We built our ASCII generator using Java. Images are loaded in from inside the project's directory, parsed, and displayed on a JavaFX window. Since we wanted full color ASCII art and thus needed to set the colors of each individual character, this required HTML; we thus formatted our result data into HTML and CSS and used JavaFX's WebView engine to render the HTML. For GIFs, a timer runs, with a certain period, each time updating and re-rendering the HTML code of the WebView to the current frame.

Challenges we ran into

The most notable were performance issues. A normal GIF that we used has around 150 frames - each frame then has around 80 rows and 250 columns of pixels; this makes for around three million characters for a given GIF, each character with their own verbose HTML and CSS tags. As a result generating ASCII art for GIFs was crippling slow; we alleviated this problem with heavy optimization of our conversion algorithms and usage of alternative, faster string concatenation methods.

What's next for AsKEE

Our vision for the future of AsKEE includes generation of ASCII art animation for not just GIFs, but videos as well - in addition, we are thinking about porting this to bash to create more interactive and powerful terminal GUIs using ASCII art.

Built With

Share this project:
×

Updates