ever wanted to convert your image to Ascii characters? here is how you can achieve it!!
we will be converting this image of Mario, into ascii characters
step 1:- loading in the image and resizing
we resize the image since there are a LOT of pixels. so we resize it by 50%! this will make the final output smaller and we will not be compromising on the quality(since there are a lot of pixels to begin with!)
step 2:- converting the image to a pure black and white image
here we convert the image to a pure black and white image. we do this since text characters don't have color. now we can save this black and white data to a new image
here is what the image looks after the conversion!
step 3:- converting this black and white data to text characters
here we read in the data from the fresh black and white image which we saved in the last step. we also have a count variable which helps us to break the line for every time we finish a row section of the image
now we check the color of each of these pixels, if its black(0), we simply write in a "~". on the other hand if its white(255), we write in a "."
we now save this data into a text document!
here is how it looks like finally
I have resized my code editor so you all can see this masterpiece!
Top comments (0)