Image to ascii conversion tool
Switch branches/tags
Nothing to show
Clone or download
Latest commit f907d53 May 5, 2018

README.md

asciimg

Simple image to ascii art conversion.

Shell integration

To plot images in the terminal using all available space, add an alias in your shell's configuration file:

eg. for zsh:

alias img='f() { ./asciimg "$1" -res ${COLUMNS}x$(echo ${LINES}-1|bc)};f'

Options

Switch Description
--res WIDTHxHEIGHT Sets the rows and columns to use for rendering
--threshold VALUE Thresholds the pixel values
--invert Inverts the pixel values

Samples

asciimg lena.png 100x50

%%%tt%t%%%%ti:;;;;;;;;iiiiiiiiiiiiiiiiitiiiiiiiiiitiiiiiiiiiii;itt%tt%tttt%t%%t$$@$;;iiiiiiiiiiiiii%
%t%t%tt%%%%ti:;;;;;;;;iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii;;it%ttt%t%t%ttttt$@@%;;iiiiiiiiiiii:.
t%%%tt%%%%%ti:;;;;;;;;iiiiiiiiiiiiiiiiiiiiitiiiiiiiiiiiiiiiiii;;;it%%%%%%%%%ttttt$@@X;;iiiiiiiit:...
%%%%%%%%%%%t;:;;;;;;;;iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii;;it%%%t%%%t%t%tttt$@@$;;iiiiii,.....
%%%%%%%%%%%t;:;;;;;;;;iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii;;;ittt%%ttttt%ttttttX@@$;;;ii:..,,,..
%%%%ttt%%%%t;::;;;;;;;iiiiiiiiiiiiiiiitttt%%XXXXXXt;iiiiiiiiii;;;ittttttttttttttttttX@@@ii:...,,,...
%%%ti;t%%%%ti:::;;;;;;iiiiiiiiiittiiititi%t%X%XXXXXX$X;;iiiii;;;;itttttttttttttttttttt@@@...,,,.,...
%%t;:;t%%%%t;:::;;;;;;;;;iiiiit;i;iiiiitittt%%XXXXX$$$$$t;;;;;;;;itttttiittttttttttttt%:....,.,..,,.
%t;::;t%%%%t;:::;;;;;;;;;iiiii;;iiiiiiiiiiit%%XXXX$XX$$@$@@:;;;;;;tt%tti:;ttttttttttti.......,..,,:t
i::::;t%%%%t;::;:;;;;;;;iiii;;;;iii;iitttttttXX%X$$$$$$$$@@@t::::ittttti,.;itttttttt:...,,.,..,,:ttt
:::::;t%%%%t;::;;;;;;;;iiii;;i;;;iiiitiitiitt%$XX$$$X$$$$$$$$@X,:;t%ttti,..:itttttt...,,,.,.,,,itt%%
:::::;t%%%%t;::;;;;;;;;i;%;;;;;;iiitiittiitXXXXXX$$X$$$$$$$$$$@@,;itttti,....X@$$i...,,,,,,,.;ttt%%%
:::;:;t%%%%t;,::;;;;;;;;;X;;;;;iiii;iii;%X%%XXXXXXX$XX$$$$$$$$$@@:i%ttti,.,@%@@@@@..,,.,..,,ttt%%%%%
;;;;;;t%%%%t;::;;;;;;;i;$t;;;;ii;iiii;%%t%%%XXXXX%XXXX$$$$t$$$$$$$$tttt;$X$$$$$$@@.,,,.,,..ttt%%t%%%
;;;;;;t%%%%t;:::;;;;;;;:$%i;;;;;iiiittti%%t%%XX%XXXXXXX%XXXXX$XXXXXX%$XX$$$$$$$$@@.,,...,:ttt%%%%ttt
;;;;:;t%%%%ti::;;;;;;;;:$ttt;;;i;itttitttt%XtX%%%X%%%X%XXXX%XX%X%$XX$$$$$$$$$%X$$..,,..,:tt%%%%%%%%%
;:;:;;t%%%%t;::;;;;;;;:;XX%i;;;itititttttttt%%%%%%%%%%%%%%%%%%$X$$$$$$$$$$$$%t%Xi..,.,,itt%%%%%%%%%%
;;;;;;t%%%%ti::;;;;;;::i$X%ttiiiiitttitttt;ti;;t%;;t%iti,tt$%$$$XX$$$$$$$$Xt:;X$....,,;tt%%%%%%%%%tt
;;;;;it%%%%%i::;;;;;;;::$XXitii;itiiiiittiii;;,,;:;:,,..XtX$$XX$$$$$$$$;:::;%$,.,.,,.;tt%%%%%%%%t%%t
;;;;;;t%%%%%i:::;;;;;;;:$$Xtti;ii;iiititi,:,..:;,i:..:%t$XXXXXXXXX$i;;t%%%%$..,,..,.;tt%%%%%%%%tt%%t
;;;;;;t%%%%%i:::;;;;;;;;:$$%%ii;iiiiii;::,.i.,:,,;.,;%$XXXXX%XXXXX:;;t;tXX...,,,..,,ti%%%%%%%%%%%%t%
;;;;:;t%%%X%i,::;;;;;;;;;:@$iiiiiti:::,,,:,,;..,.::%XXX%%XXX%$$$$$%;.:it;...,,,...,ii%%%%%%%%%%%%%%t
;;;;;;t%%%%%i:::;;;;;;%;;;$%;;;i;,,:;.,..,,,:..,iX%i%X%%Xt%XX$$$$$$i,.,%,..,,,..,.tittttt%%%%%%%%%%t
;;;;:;t%%%%%i::;;;;;;;;iiii%;iii..:,..:,.,.:.itt%XXtX%%t%%XXX$$$$$$%:..t;,,,,,,,.itt%%%%%%%ttttttttt
;;;;:;i%%XX%i:::;;;;;;iii$,.ti;,;.;,,,..,,..;;%X%X$%:;;i%XX%XXXX$$$t,..,t,,,,.,.:tt%%%%%%%%%%ttttttt
:;;;::t%X%X%i::;;;;;;;;t%t%t:,:::.:...;....%X%$XX:;:::,ii;t%%XXXt;,,,,.,%,:,,.,,ti%%t%%t%%ttt%t%tttt
;;;:::i%XXX%i::;;;;::%Xttt,.:,.::,..i...,:t$X$$;:.:;,;$::;it%@i,.;%,...,%;:,,,.itt%%ttttttttttttttti
;;;:::i%XXX%i::;;;.:ttX,,;:,..,ii,....,..:%X$;iitti;iit%tiitX@%tit:,,.,.%:,..,;tt%%ttt%tt%ttttttt%XX
;:::,,i%XXX%i::;;;i;:;,.,;,,.:.t,%...,,,;XX%:iitt%%%%%%%ttii%@X%tii;,.,.%i..,.ii%%tttttttttttiX$$XXX
::,:,,i%XXX%i::;;i:;:,:,t,,..,,,.;;...:iXX.,;iitt%%%X%%%ttiit@X%ttii,,,.t%.:.:t%%t%tttttttti%$X$$X$$
:::,,,i%%%X%i::;ti.i;,:;t,,,..,:,tii..;$$.,,;iiitt%%%%%tiiiit$@%tti;.,,.it.,.tt%%%%tttttttiX$XX$$$$$
:::,,.i%%XX%i:;i;;,:::i,,ti,,.:ii,..%ti%..:,;iiitttt%%tt;ttiiX@ttii..,,.,%;.it%%%ttttttttiX$XX$$$$$$
:::,,:t%%%X%i::;i:,,.i:,;i:..t..,::itX.,,.::;iiiitttt%%tiiiii%%tti.,.,,..%t.tt%tttttttttt%$$$$$$$$$$
:,,,,;t%%%X%t::;t;,t,,:,::ii:,.,%Xi:%...,,:;;iiiiitttttttt%$X$%ti,,.,::,.ttitt%tttttttttiX$$$$$$$$$$
,,,,,:t%%%X%t:;:;,,;,,,;;,;;;;i$$;i..:..:..::;iiiitt;iiiiiiii;;t,...:::,.;;tt%%tttttttttiX$$$$$$$$$$
,,,,:;t%%%X%t;:i;,t.,,,t,;;,it;Xi%,,..,.,,,::;;iiiittiiiit%tttt..,.,.::,.:t%t%%tt%tttttii$@$$$$$$$$$
,,..;;itXXX%t::::,,.:,tit;ii,itX,,.,,,,,,,.,,::;;iiitiiitttttt,..,,,.::,,.%t%%t%tttttttii$@$@@$$$$$$
.,.,:;itX%X%t::i,:..:,i:,i;ii:;,,,,,,,,,.,,,,,.,:;iittt%%%%%t.,,,,..,,:::.%tt%tttttttttit@@$$@$$$$$X
.,..::i%%%%%ii;t.;,,,.:i:,ii:t:%...,.,.,...,,.,:;iitttt%t%%XXi,,,,,,,:::,,ti;iiiitttttii$@$$$$$Xi..,
ii:,,,;t%%%Xi,t...:.,::,i,t;;i;t:t,:.:..,..,,,,:iiiiiitttt%XX$$$$%..::::::tttiiii;;;;;;:$$$$$$t.,,::
itti:.;t%%%%tt:...,:,,;:.,,,:ii%.ii,.:,,,,,,,:.:;i;titttt%%%XXX$$$$@,:,:,itttttttiii;iii$$$$X.:::;;:
.;%%t.:%%XX%t;..,;.,,,,.,;;;,;;i%.ti.:,,.,..:i.:iiiitttttt%%%XXX$$$$@$.,.%tttttttttiittX@@$X:::;;;;;
.,t%t.:tXXX%ti,.....i.:.,.,:i:;t%.;:.::,.,.,;i,;iiittiitttt%%%XXX$$$$@$..tttttttitiit$$$@@X;:;;i:;;;
..iX%,,tXXX%t;,..,,,i,.,,.,;,iit:tt..,,,,.,;ii,;iittiittttt%%%XXX$$$$$@,,ttttttttiii$@$@@Xi;;;;;:;;:
..;%%:,t%XX%t;,...,.,,.,...,,:;;i:..,,,,.,:iii,iiittttittttt%%%XXX$$$$$@;ttttttttiiiX$$@$i;;;;:;;:;:
..:%%;:t%%X%ti,....,,,,.....i:.i.;i.....,:;ii,;iitttttititttt%%%XXX$$$$$%;;;;itttttttt$@%;:::,;;:;;:
..,%Xt,t%XXXti:,..,.,,,,.,.,;tt;;.,....,:iii.;iitttttttitttttt%%%XX$$$$@@:;:::,,,,;X%$@X:,::;;::;;:,
::;%X%:t%XXXii,...,...,,..,,,,,i:.....,:;;.,iiiiittittttitttttt%%%XX$$$$$X;;;;::,.i$XXi,,,:;;::;i;:,
.:;tX%:i%XXXt:,.,,,:,,,:;,:,;,;%,.,....,:;iiiiiiititttttttttttt%%%XXX$$$$$::;;;;;;;t:::::;;:,:;i;:,,
.,,i$$ii%XXX;,,.,,,,.;.,,i.i.:.::..,:;;i;iiiiiiiitittttttttttttt%%%XXX$$$$$:;;;ii;i;;i;:;:,,;ii;:,,,

asciimg avatar.png 100x55

....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
...............................................,,,,,,...............................................
.......................................,,,,,,,,,,,,,,,,,,,,,,.......................................
...................................,,,:;;;iiiiiiiiii;;;;ii;:,,,,,...................................
.................................,::;;;;:,,,,.,;;;;;;;;;;;;i;;;::,,.................................
................................,:::,,....,,,,,,,::;:;;;;::::::;;;:,,...............................
..............................,,:,,,,.,:iii;;::,,,,:::;ii;;:::,,,::;::,,............................
.............................,,::::i%XX$$$$$$X%tttiitii;;;;;;::,....,:::,,..........................
............................,,::;%$@@@@@@@@@$$$XX%%%XXXXt;;;;;;;;;:;;;;::::,,.......................
...........................,,,,%$@@@@@@@@@@$$$$$$$$$$$$$$Xt;:;;;;;;;;;;;;;;:,,......................
..........................,,,,X@@@@@@@@@@@$$$$$$$$$$$$$XXX%t;::::,:;;::::::;;,,.....................
.........................,,,,%@@@@@@@@@@@@@@$$$$$$$XXXXX%%%ti:,,,,,,,,:::,::;;:,....................
........................,,::t$$@@@@@@@@@$$$$$$$XXXXXXX%%%%tti;,....,,,,:::::::;,,...................
........................,::iX$@@@@@@$$$XX%%%%XXXXXXXX%%%%%ti;;:..   ..,,,::,,:;;,...................
.......................,,:;%$$$$$$$$X%t;,.,,,;::;it%%%%%%%%ti:,,..    ..,:,,:::;:,..................
.......................,,:i%X%%XX$$X%i:,,.,,:;;;;;;;t%%%%%%tt;:,..      .,,,:::::,,.................
........................,:::,::iX$$Xt;,..........,::;it%%%%%ti:,...      ..,,,,:::,.................
........................,,:;;;it$@$Xt;:,.,:iii;::,:;;i%%%%%%%t;,....      ..,,,,,:,.................
........................,,;;,,%@@XXX%%i;;;;ii;;;it%%%XXXXXXX%t:,,,..      ...,,,,:,.................
........................,,::;X@$$XXXXXXXXXXXXXXXXXXXXXXXXXX%%i,....     ........,:,.................
.......................,,:;t$@$$XXX%XXXX$$$$$$@$$$$$$XXXXX%%t;,....   .,:;:,....,:,.................
.......................,,:iX$X%%%%%XX%%%X$$$$$$XX$$XXX%%%%%%t:. ....,;;:::;;:...,,..................
......................,,::%%%i;:,,:;iiiit%%%X%%%%%%%%%%%ttttt:...,,:;;;;;;;;;,..,...................
......................,,:tXXt:,,....,,;iitttt%%%%%%%%%%ttttii:,,,:;;;;;itti;;:..,...................
......................,:;XXX%t:,....,:ittttttt%%%%%%%%ttttii;:,,,;iii::;itii;..,,...................
.....................,,:;XXX%%;,,....,:;;iit%%%%%%%%%tttii;;::,,:iiiiiiiitii,..,....................
.....................,,:;%XXt:,,::,,...,...,it%%%%tttttii;;::,,:;iit%%t%tti,  ......................
.....................,,,;%%i,,:::;iii;;::,,,;iiitttttiii;;::,,::;;it%%%tti,  .......................
......................,,;ti,,:ittiiiiitt%%%i;ii;;;iii;;;:::,,,::;;:,,::,. ..........................
......................,,:t;::iti;::;it%%%%ttiii;;:;;;;;;::,,,,,::;:,.      .........................
......................,,:iiittti;;;;it%%tttii;;;::::::::,.....,,::;;:,     ,........................
......................,,,iiit%ti;;;;;;;;;::,,::::,,,,,....  ...,:;i;;,.   .:........................
.......................,,i;;;;;:,,,,................ .        .:;iii:,.  .::;,......................
.......................,,i::,,.....                          .,:;i;:,.. .,::::,.....................
........................,::,..                              .,:;;;::,...,..,,:,.....................
.........................,,,.                              .,::::::,..,.  .,,::.....................
...........................:,                            .,,::::::,.... ....,,,,....................
..........................,,,                          .,,,::::::,......,,,....,....................
.........................,:  ..                      .,,,,:::::,,.....,,,,......,,..................
.......................,:.   ,::.                 ..,,,:::::,.  .   .,,,...     .,,.................
.......................,,.  .,::.            ....,.,,,..           ..,,...      .,,.................
......................,:..,...,,.  ......                           ....       ..:,,,...............
.....................,;,.,,,,...                                              ..,::;:,..............
....................,::,,,:::..                                              .,:::::;;,,............
....................,:,..,:::,.                                              ..,,,,,:;,,,,..........
...................,,;;:,..,,,.                                             ......,,::;;:,,,,.......
....................,;;:,,.                                               ....  .,,,,::::;;:,,,.....
.....................,,:;:..                                             ... ..,,,,,,:::::::;::,,,..
.....................,,,,,:,                                                ..,,...,,::::::::::;;:,:
..............,,,,,,,,,,,,,,.                                             .........,:::::::;;;;;;:;;

asciimg avatar.png 50x27

..................................................
..................................................
..................................................
.......................,,,,.......................
..................,:;i;iii;;ii:,,.................
................,:,..,,,,::;;:::;:,...............
..............,,:;X$$$$%tttt;;;:,.,:,,............
.............,,;@@@@@$$$$$$$$%;;;;;;;;:...........
.............,:@@@@@@@$$$XXX%ti,.,,:::;:..........
............,:$$$$$Xt;itXX%%%t;,.  ,,::;,.........
............,ittXX%,...,:;i%%%t:..  .,,:;,........
............,;;;@X%;:;i;;:i%XX%;,.   ..,,,........
............,;%@XXXXX$$$$$$XXX%,..   ...,,........
...........,,t%iit%t%XXXXXX%%tt..,::::;.,.........
...........,:X%,..,ittt%%%%ttii,,i;:tii.,.........
...........,;X%,,,...,t%%%%ti;::;itttt............
...........,:t,:ttiitt;iiiii;:,:;;it;.............
...........,:iit;;t%%ti;::;::,,,:::   ............
............,;ii::,,,...,...   .;i;. ,:...........
............,:.                :;:,.,,:...........
...............              .:::,.. .,:..........
.............:..           .,:::,..,,.............
............, .:.       ..,,.     .,.    ,........
...........;.,,.                       .,;:.......
..........,,.::.                       ,:,:,,.....
..........,;,.                       .. .,:::;,,..
...........,,:                        ....,:::::;,

asciimg avatar.png 25x13

.........................
.........................
.........:i:i;i;,........
.......,:$@$%%i;:::......
......,t@@@$XX%i.,::,....
......,,Xt...;%%.  ,:....
......,$XX$$$$%t. ;.,....
......;%,,tt%%i;:;i:.....
......:,;i%i;;:,;. ......
......,,.       ;,.:.....
........      ,::.,......
.........           ,,...
.....:,            ..:;,.