How to create a color ASCII image with Google Colab?
A Python package named ASCII Magic allows us change a usual image to an ASCII image. This is so amazing! Try it out!
- Go to Google Colab and sign in with your google account.
- In the Colab environment, upload your image using the left vertical menu bar.
- On the horizontal menu bar, chose “Insert”, then “Code Cell”, a code cell will be appear.
- Copy and past the following code to that code cell.
- Replace the
image_name.jpg
by the name of your image and click on the triangle symbol of the code cell to execute it. - You will get an html file located next to your image file, download it and open it with your browser, e.g. Chrome. You will see your wonderful image in ASCII style.
!pip install ascii_magic
import ascii_magic
output = ascii_magic.from_image_file(
'image_name.jpg',
columns=200,
width_ratio=2,
mode=ascii_magic.Modes.HTML)
ascii_magic.to_html_file(
'image_name.html',
output,
additional_styles='background: #222;')
Here I take myself as an example.
HHHHDDDDDDDDDDDDDDDDDDDDDDDDDDDHHHHHHHHHKKKKKKKK@@KKKK@@@@@@@@@@@@$@$$$$$$$$$UUU88U$@@KKKHHHHDDDDDDD
HDHDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDHHHHHKKKKKKKKKH@&kYbkO8$@@@$$@@$$$$$$$$$$$$$UUUUU$@@KKKHHHDDDDDDDD
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDHHHHKKKHK@$&Ydfe!{lc{I1u5gA$$UU$$$$$$$$$$$$$UUUUU@@KKKKHDDDDDDDDDD
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDHHHKH@GpTe]{%\+===^^^=/")iIupPOk8U$$$$$$$$$$$UUUU$@@KKHHHDDDDDDDBB
DDDDDDDDDDBDBDDBDDDDDDDDDDDDDDDDDDDHKHOCI%>|"/+^^;^^^^^^+/||>%]jfgYU$$$$$$$$$$$UUUU$@KKKHHHHDDDDDDBB
DDDDDDDDDBBBBBBBDBBBBDDDDDDDDDDDDDHHDbzsc<|""/""|)|""+=^^^+/\)coe6E8$$$$$$$$$$$UUUU$@KKKHHDDDDDDDBBB
DDDDDDDDBBBBBBBBBBBBBBBBDDDDDDDDDDHDkos%<"")>vl*I?!!?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/==+/==/||<<"")\\\|/=^;;;,,/||||"||\<</;;^=/""""rw4A@KKHHDDDBBBBBBBWW
MMMMMMMMRBgn*v\<))>><\\)|"/==+===+/""/"|\\>"^="||""=;,:''':;===^;^/)\\=;;^==/|\"|i[6OKKKHDDDBBBBBBWW
MMRRRMMQRP}rl<vlcc%i>\||//==^^^^/")\\))\\<>/;;^+"""//=^;:''':,;;;;;^/)|/;:,;=/)\/\\\xuUHKHDDBBBBBBWW
RRRRRRNdo%vr%<rlli<"/+/+=^;;;;;^+|\<\"/\>>>|;,;=+///+=^;,:'_':,;;;,,;^/)"^::,;=////")iy8HHHDDBBBBBWW
0RRRRQG?ri)\<<li/\\/=^;;;;;;;;;^^|<=::")))i|,,;^=++++=^;:''''':,,;;;;,;="|/;:,^"/^+")\>}dBDDDDBBBBBW
0000QKnIr%>|/+"">v)/+=^;,:,,;^^^^=,:/\>>))i",,,;^====^;;,::''''::,;;;;,,,=""/^;="/+""|\\cwg&BBDDBBBW
00Q0Parcv)<)"+;\x)|+=^^;;;,,,;;;;;/\<>>>>i)+::;;^^==^^;;,::::'''::,;;;;;,,;+|""/+"++/""|||\{fkBDDBBB
0QQS{%i>\|"//+^i%\/=^^^;;;;;;;;;^"<>>>>))i<^,,;;^^^^^;;;,,,:::'''::,;;;;;;,,^/"|""/=//"//"||\l5HBBBB
Q0dl<|"/++++==^v))/=^^;;;;;;;;^^/\<>>>)>))"::,;^^^^;^;;;;;,::::'''':,;;;;;;,,,^"""|+^===+/""|\>oGBBB
4j)|"/++=++==^/v<"=^;;;;;;;;^;^"\\<<<<<>)>^_:,;^^^^^;;;;,;;::::''''::,;;;;;;;,,;+"|"^;,;;;^=+/"|v#&W
i)><\|/+==^^^;<i)/=^^;;;;;;;^^/)\<<<>>><i\,_',;^^;;;;;;;,;,:::'''__'::,;,,;;;;;;,^/""+;,,,;;^^=+|)sS
i)><\\|/+^^^;+i\/=^^^;;;;;;;;+)<>)))i><<)"'_',;^^;;^;;;;,,::::''''_''::,,,;;;;;;;,;+""/=;,;;;;^=/""\
ii><\\|"/=^;,\>|/=^^;;;;;;;^|<<))ii)>>>>>='__,;^;^;;;;;;;,::::''''''''::,,;;,,;;;;,;^+///=,;^^^==+//
i))><\)"//+;^)<|/=^;;;;;;^=|>>>>)i)>>>>));__';;^;;;^;;;;,:::::''':'':::::,,,;;;;;;;,,;=/"/+^^^^^==++
"""""|||||/^))|"=^;;;;^=+/|\<\<>>>>>)))>='_',;;;;;;;^;;;,,:::::::::'''''':,,;;;;,;;,,,,^+///+^^^===+
==^^^^^^====)>|/=^^^^=//|)\\)\<>><<<>>)|,_',;;;;;;^;;;;;;,:::::::,::'''''':,,,;;,;;;;,,,,=///+^,:;;^
^^^;;;;;,::,<<"+==++///"|||\\<<<\\<><>>=_':,,;;;;;;;;;;,,:::::,,:,,::'_'''::,,,,,;;;;;,,,,;=+//+^,:,
^;;;,,::''_,/|""//"////"")\<<<<\\<<>>>|:':,,,,;;;;;;;;;,::::,,,,,,,::''_'''::,,;,;;,;;,;,,,,;=/++=;:
^;;,:::::'';^=/""""++/"|)<>>><\\\\\<><^'::,;,;,,;;;;;;;,,::,,,,,,;,,::''__''::,,,,,,,;;,,,,,,;^++++^
^;;,,,,::::^^^=/|"/+/")\)<>><\\\\)\\</:':::,;;,;;;;;;;,,:,,,,,;;;;;;,::'__'''::,,,,;,;;,,,;,,,,;^=++
^;;;,,,,:::^^^=+"//")\\|\)><<<\<\\\<);''':::,,,;,;;;;,,,;;,,,;;;;;;,,:::'___'':::::,,,,,,,,,,,:,,;^^
=^;,;,,,:';^^^^=+")\\)|))><\)||)\\<<=:'''::::,,,,,;;;,,,,;;,,,;;;;;;,,:::''_''':::,,,::,,;:,,:,,,,,;
==^;;,,::';;^^^=/|||"")>><)|""|)\\>",''':::::,,,,,;;,,,,;;;;;,,;;;,;;,,,,::'''_'::::,::,,,,,,,,,:,,,