If I have a plain text file, how can I convert it to an image file through the command line? (and preserve the layout of the ASCII art in it) 
How to transform a text file into a picture
command line
imagemagick is your friend here. Something similar to the following may help you:-convert -size 360x360 xc:white -font FreeMono -pointsize 12 -fill black -draw @ascii.txt image.pngwhere ascii.txt is your ascii-art file:-text 15,15                  .88888888:.                 88888888.88888.               .8888888888888888.               888888888888888888               88' _`88'_  `88888               88 88 88 88  88888               88_88_::_88_:88888               88:::,::,:::::8888               88`:::::::::'`8888              .88  `::::'    8:88.             8888            `8:888.           .8888'             `888888.           .8888:..  .::.  ...:'8888888:.         .8888.'     :'     `'::`88:88888        .8888        '         `.888:8888.       888:8         .           888:88888     .888:88        .:           888:88888:     8888888.       ::           88:888888     `.::.888.      ::          .88888888    .::::::.888.    ::         :::`8888'.:.   ::::::::::.888   '         .::::::::::::   ::::::::::::.8    '      .:8::::::::::::.  .::::::::::::::.        .:888:::::::::::::  :::::::::::::::88:.__..:88888:::::::::::'   `'.:::::::::::88888888888.88:::::::::'         `':::_:' -- '' -'-' `':_::::'`      with text 15,15 added as the first line of text (the 15,15 is a positional offset).  Also, make sure that the actual text to be converted is enclosed in quotes.  Single or double quotes will do, but make sure they're not used as part of your ascii-art as it will confuse matters.The font you choose should be a monospaced font, otherwise the text won't align.This produces:-