Skip to content

Instantly share code, notes, and snippets.

@JayantGoel001
Created January 6, 2021 14:07
Show Gist options
  • Save JayantGoel001/b680358e32b2f7909957c67238a32537 to your computer and use it in GitHub Desktop.
Save JayantGoel001/b680358e32b2f7909957c67238a32537 to your computer and use it in GitHub Desktop.
Convert image into ASCII Art
import pywhatkit as kt
import matplotlib.pyplot as plt
filename = input("Enter the filename : ")
target_image = filename.split('.')[0] + ".txt"
img = plt.imread(filename)
plt.imshow(img)
plt.show()
kt.image_to_ascii_art(filename, target_image)
with open(target_image) as f:
text = f.readlines()
for i in text:
print(i[:-1])
@JayantGoel001
Copy link
Author

JayantGoel001 commented Jan 6, 2021

image_ascii
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ %$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ %%%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ %%%%%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ %%%%%%%%%%%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ %%%%%%%%%%%%%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$%%%$$$$$$$$$$$$$$$$$$$$$$$$$$$%$$$$$$$$%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$@@@@$$$$@@$$$$$$%$$$$*%$%@@$$$$$%%**%$$%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ @@@@@@@@@@@&&&@@@@@@&#&@$$%%%$$%!!%%@@@$$$%%**!%$%%%$$%%$$$%$$$$$$$$$$$$$$$$$$$$ &&&&&&&&&&&##&&&&&&&&&##%%%*%$$%!!*%@@@$$$%%****%%$%$$**$%%%$$$$$$$$$$$$$$$$$$$$ #################&&#&&#&!!%**%$%!!*$@@@@$%%*****$$$%$$*%%%%$$$$$$$$$$$$$$$$$$$$$ ################&%*@####!!*****%*!*$@@@@@$%****%@@$$@$%$$$$$$$$$$$$$$$$$$$$$$$$$ &###############&*!*%&##%!!****%***$@@$@@$*$*%%$$%%$@@$$$$@$$$$$%%%%$$$$$@@@@@$$ &&&&&############@**!*%&#*!***%%%**%$%$@@%%$*%%%*$$@$@@$$@@%%****%*%$$$@@&&&@$$$ &&&&&######&@&####@%**!*$@****%$$%***%$@@%$@*%%*%$$%$@$$@@%**!!!***%$$$$@&&@@$$$ &&&&#######&!!!*$&#&%***!*%%%%$$@@%%*%$@&$@@%%%*@$$$@@@@@$%*!!!**!!**%@###&@@$$$ &###########&*!!!!*%$%*%%***%%$@@&@$%$$&&@&@%$%@$$$@@@@$$%!!!**!!!*%$@#S##&&@@@@ #######SS#####%!!!!!!**%%$$%*%$@@@&&&@@&##&@$@$@$@@&&@$%*!!*%****$@@@&SS#&&&&&&& ############@%%!!!!!!!!!%$$@$%$@@@@&@$$$@@@@$@@&&&&&@@%***%%*%$@&&&@&&$%%%%%@### #####&*****%*!!!***!***!*@&&&@@$%%%%%%%%%%%%%%$@@&##@***$$$$@&&&&&&&&@$$%*$&#### ######@*!!!!!!!!!!*******%@##@%**%%%$$%$$%%$$$%%$$$$%%%@@@&&&&&&&&&&&&@*%&###### ######SS#@%!!!!!!!!!!!*%$$$%%**%%$$$@$@$@@@@@@$@$$$$$$@&@&@@@@@@@&&&&&&&######## #&@$%***%%%*!!!!!********%%**%%$@@$$$$$$$$$@@@&@$@@@@@@@@$$%%$$@@@$@@&&&&&&&&&&# ###&&$%************%%%%$$***%$@$$$$$@@@&&@&&@&&&@&@@@@@@$$%%%%*********%%$$$@&## ##&@@@$$$$$$%%%%%%%%%$$$%**%$@$$$@&#SSSS#S#&&&&&&&&&&@&&&%***!!!!!!!!!!!*%%$$@## @%*****%%$%%%%*****%%%%%**%$@@@$@#S#####&@####&###&#&&#&&$***!!!!!!!!***%@@$@### #&%!!***!!!!!!!!!*****%%*%%$@$$$#S##@&&@&@&&SSSS####&&&##@*****%%$$$@@@&&####### &&@%**%%**************%**%%$@@@@S##&@@@$@@@@&##SS###SSSSS#@$$$%%%$$$@@@&######## &&@%%%$@@%***!*!******%%*%%$@@&&&&&@@@@@@&@@@@&#SSS#SSSSS&*!*%%$$@@@@&&&&&&##### &@$%%%%*******%%%%%%%$@$%%$$@@&&&#&@@@@@@&$@&@&##S**SSSS#%!!!!!!!!**%%$@@&&&&&&& &@%%****%%%%%%$$$$$@@$$$%%%$$@&&&&&@@@@@@@&SS###SSSSS**S@***!!!!!!!!!!!!!*%$@&&& @$%***%%%%**%$@@@@$$%****%$$$@&&&&&&&#####SS**SSSSS***S&$!!!*!!!!!!!!!!!!*%$@&&& &@$%%%**!**%$$$%%*!!!!!*$$$$$@@@&####SSS#SSS***S*SSS**#&@*!!!!!!!!!*%$$$$$@&&&&& &#&$*!!!!***%%*!!!!!!*$$%*%@@@@&#&##SSSSSSS*********S&%$$**!!!!!!!!!!*%@@$@&&&&& &##&@$$%*%***!!!!!*%$@%**!*%$@&&&&##SSSSS*********S#%!!!!**%%***!!!!!!!!%@&&&&&@ &&&&&@$$%**!!!!*%$@@%***!!*!*%&##&###S*SSSS***SS#&@%!!!!!!!!*$$$@@@&@$%**%&##&&@ &@@@&&&&&$***%$@@$%*!**!!!***$*$$&SSSS*****SSS$****!!!!!!!!!!*%$@@&&&&&#&&&####& @@@@&&#@$%**%%%%*!!**!!!!*%*$%***$%%@@@@@@@%%*!!!!!!!!!!!!!!!!!*$@@&&&########&# @@@@@@@%**%%***!!**!!!!%%%*%%*****!!!!!!!!!!!!!!!!!!!!!!**!!!!!!%@@@&&&&&####&@& @&&@@@&###&@%**!!!!!!*%%*%$%*!****!!!!!!!!!!!!!!!!!!!*!!!%$$%*!!!@&@&##&&#SSS#&@ &&&#&&&###&$*!!!!!!*%%*%$$%*!***%!!!!!!!!!!!!!!!!!!!!*****%@@&@$*%&&&##&&&###### ########&&&$%%*!!!***!%@@%*!***%%!!!!!!!!!!!!!!!!!!!!!%%%$$$@&&&@@@@&&&&&@&&#SS# ########&&&&&$!!!!!%%!@@$*!**!%@**!!!!!!!!*!!!!!%*!!**%@%$@&@@&&&@&##SS#&&@@&@@@ #&&@@&&&&&&&@$%%%**%*%&@%!***$&@**!!*!!!!*%!!!!!$$%!***&&@@&#&&&#&##SS#&&&&&&&&@ #&@$%$@##&&&@@@@$$$$%$&@**$%&#&@%**!%*!!!$$%!!!*#@@@%**&&&&#####S#&&&&@@&&&@&&&& #&@$$%@&&@@&&###&&&&&&&$%@&&&@@&$%**@%!!%@@$$!!%SS&&@$@#&&######S#&@@@$@@@@$$$$@ &&&&@@@@@$@&##########&$@&&&&&#&&*$$&@*!&##&@$*&S*S&&&##&&&&&&&&&&@$$@@@$@@$$$$@ &&&&&&#&@$$@&#####&&&&&&&######&&&&@@@@$####&@$&S**#&#&&&&&&&&&&&&&&&&&&@&&@&&@$ &&@$$@&&@$$@&#########&&&##########@@&#####&&&&&#**##&####SSSSSSS####SS######&@$ @@$%%$@@@@@&###&&&##########SS#####S#######&&#S#&S*S#&S**S##########SS#S*S###### @$%%%$@&&&####&@&&###&&#####S######SSSS########S#SSS###SS#&&###########S*SSS#### &@$$$@&###S###&&&###&&&&&&#######&&#############SS*S##S#######S######&#SSS###&&& #&@@@&##SS###########&&&&&####&&&@@@&&#######&&@&S*S##S###############SSSS##&@$% ###&&&##SS############&&&&####&&&&$$@&#&$@$%%***$S*S#&###############SSSS###&&&& ##&&@@&##SS###########&&&######&&&@$$%%%********&S*S###SS####&&&&&&#SSSSSS###### #&&@@@&&###S########S##&&&&&@&&#&&&@$@&##&@@%*!$#S*SSS#SSS########SSSSSSSS###### ##&&&&#########&#####SS#&&&@@@&###&&@&SSS####@*$#S*SS##SSS&&#####S*S##SSSSS##&#S &&&####SSS###S#&&&&###SS#&&&&&&###&&@&SS**S###@%&##S##SSS#&@@&##SSS##SSSSS#&&&S* &&####SSSSS##SS#&&&####SS####S#####&@&##S**S###$@&@##SSS##&&@$@#SSSSSSS#&&S#S*** &####SSS#####SSSS##S###SSSSSSSSS###&&&###S**S##&&$@######&&&#&$$&####SS&$@SSSS*S &S#####&##SS##S***SSS##SSS####S####&&&S###S**SS##$@###########&@$@&@@$$$%$$$$@S* #*########SS###SS**SSS##SSS#&&####&&&#S####S**#&&%@##SSSSS####@$%%%%$%$$@@@&##S#

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment