Monday, June 15, 2015

Image to ASCII ART converter in Java

English: ascii art example. "Block" ...
English: ascii art example. "Block" or "High ASCII" style, cf. ANSI art. (Photo credit: Wikipedia)

ASCII art is a graphic design technique that uses computers for presentation and consists of pictures pieced together from the 95 printable (from a total of 128) characters defined by the ASCII Standard from 1963 and ASCII compliant character sets with proprietary extended characters (beyond the 128 characters of standard 7-bit ASCII). The term is also loosely used to refer to text based visual art in general.
-- From Wikipedia

Ascii Art is pretty cool and there are several online services available which allow you to use convert an image to its ASCII ART form. These are often used in image boards or online communities as Avatar images. So I made a little java program which takes an image and converts it to its ASCII form.

How to Use ?

This code doesn't takes command line input so you need to pass the image name with extension in the main function.

Example :-

obj.convertToAscii("Absolute_Path_To_Your_Image.jpg");

When you run the code a text file "asciiart.txt" is created which has the Ascii Art of the image you gave as input. For better vision of the converted image set the font size to 2 or 1. 
Source Code
Sample Run :-

The image I used is :-

[Image: 2YpkRjy.png]

The output is (See the text in notepad)

[Image: i0J2jdp.png]
Sample Demo 2
Input Image
 
Output
I hope you learned something new and will be using this code to make your own ASCII art from images. See you later :) 

0 comments :

Post a Comment

Follow Me!

Blog Archive

Followers

Visitor Map