Making An ASCII-ART GENERATOR!? [PYTHON BEGINNER PROJECT TUTORIAL]

  Рет қаралды 28,831

Raphson

Raphson

Күн бұрын

Пікірлер: 96
@Akascape
@Akascape 2 жыл бұрын
Hello, I have figured out the solution for the issue of converting some png images. It used to fail the process with only 32 bit png files because it cannot process the alpha channel of 32 bit depth. So just a simple solution is to change the line no.21 "im = Image.open('file.png')" with "im = Image.open('file.png').convert('RGB')" which will simply remove any alpha channel from the image.
@Raphson
@Raphson 2 жыл бұрын
Well found, sir!
@nomadautodidact
@nomadautodidact 5 күн бұрын
Fantastic tutorial bro!!! Perfectly edited!!
@jacksonbernardo670
@jacksonbernardo670 3 жыл бұрын
Dude this is awesome! I cannoy believe that this program was made in Python :0
@notyrants507
@notyrants507 8 ай бұрын
Thank you so much! I did this just for fun but it was super good to do it to learn new packages and some new loops! Thanks!
@Raphson
@Raphson 8 ай бұрын
Happy to help!
@csbluechip
@csbluechip 4 жыл бұрын
Awesome ... It's like listening to the inside of my head while I'm coding LOL
@TSPTHUNDER
@TSPTHUNDER 4 жыл бұрын
till 5:21 .....i write and when i run the black and white image is not generated ...i use pycharm....plz help
@TSPTHUNDER
@TSPTHUNDER 4 жыл бұрын
and it says 'method' object is not subscriptable at r, g, b = pix[j, i] line
@Raphson
@Raphson 4 жыл бұрын
Could you first try to use a different image? Some PNG's apparently have a different structure or so, that might cause this.
@TSPTHUNDER
@TSPTHUNDER 4 жыл бұрын
I am trying... For two days....i also mail u plz check the mail...and help me.... Its saying error in ImageFont.py line 836 833 193.....that means the package.... How is it possible... I'm frustrated man...plz help...
@Raphson
@Raphson 4 жыл бұрын
Haha okay man I have time tonight to check it, okay? I'll be back.
@abhradeepdey9054
@abhradeepdey9054 3 жыл бұрын
Tyvm, i actually learnt some concepts of image processing
@blockchaindomain
@blockchaindomain 3 жыл бұрын
I keep getting this error on alot of my photos.. any tips? Traceback (most recent call last): File "D:\ASCII\Asciigen.py", line 35, in r, g, b = pix[j, i] TypeError: cannot unpack non-iterable int object [Finished in 0.208s]
@Raphson
@Raphson 3 жыл бұрын
Yeh its a bit older and some png's are different than others. Ive recently tried the code again and indeed there are some weird issues, probably header format of the png. Sorry that I cannot give you an exact solution.
@blockchaindomain
@blockchaindomain 3 жыл бұрын
That's okay I learned a lot from your video and I appreciate you making this easy to understand
@hypercsgokl6220
@hypercsgokl6220 2 жыл бұрын
how do i add the image to the thing i've got a jpeg, but i have no clue on how to add the image onto the project
@PaulJoshi
@PaulJoshi 4 жыл бұрын
Dude this is Gold!!❤❤
@GeneralBlorp
@GeneralBlorp 3 жыл бұрын
Great job!
@richardfeynman3856
@richardfeynman3856 4 жыл бұрын
Круто, мужик! Я очень впечатлён. Very cool man! I'm impressed.
@Raphson
@Raphson 4 жыл бұрын
Thank you!
@mageshkumar3318
@mageshkumar3318 3 жыл бұрын
i am running this in visual studio code idk where my out put is
@vanmanhtran4813
@vanmanhtran4813 3 жыл бұрын
Thank you, guy! But I have one problem: how to print output on terminal instead of render png file? Thank again.
@Raphson
@Raphson 3 жыл бұрын
Simply use pythons print command!
@vanmanhtran4813
@vanmanhtran4813 3 жыл бұрын
@@Raphson I have no idea in order to print with file png :(( pls assist me
@fahadkhan-qz7nz
@fahadkhan-qz7nz 3 жыл бұрын
Bro, i love the way u code
@Raphson
@Raphson 3 жыл бұрын
Thanks man!
@barteksful
@barteksful 3 жыл бұрын
Is it possible to generate more pictures at the same time? For example, I have 100 images named 1.png, 2.png etc and would like to convert them to ascii faster than individually. What would I have to do in this case?
@Raphson
@Raphson 3 жыл бұрын
Hey man! Yeah that is definitely possible. What I would suggest is using a for-loop. A loop has an iterator, that cycles from 0 to 99. You can use that number to open the different files. Say you have those 100 images, you can open 0.png by creating a string from that iterator. Something like: str(iterator)+".png", or similar. You can save the files also from that loop, using the same strategy to name the files. Don't hesitate to ask more if you do get stuck. Cheers.
@joedew4183
@joedew4183 3 жыл бұрын
**FIXED** the part "d.text((j*oneCharWidth, i*oneCharHeight), getChar(h), font = fnt, fill = (r, g, b))" does not work for me. Heres the error code Traceback (most recent call last): File "C:\Users\joeve\Desktop\Python\ASCII convertor\main.py", line 38, in d.text((j*oneCharWidth, i*oneCharHeight), getChar(h), font = fnt, fill = (r, g, b)) NameError: name 'd' is not defined
@henrykidman4364
@henrykidman4364 3 жыл бұрын
how did you fix it ?
@S_whoelse
@S_whoelse 2 жыл бұрын
I installed Pillow but its telling me that there isnt a module named "PIL"?
@Raphson
@Raphson 2 жыл бұрын
Try finding an updated turorial just on how pillow needs to be adressed. It might be initialised differently, as this video is 3 years old now! The rest of the code will be the same methods though!
@pranavsridhar1902
@pranavsridhar1902 3 жыл бұрын
Hai,how to copy the path of the font?
@kwkwbwjsj
@kwkwbwjsj 5 жыл бұрын
Nice video! but I have some problem following your intructions. I typed the exact thing like you and my txt file looks like its extended in up and down side. what would be wrong with my file...? Also it seems side part of the characters are torn away
@Raphson
@Raphson 5 жыл бұрын
Hey man, thanx! I think maybe you got line wrapping enabled in your notepad? Also, for that extending part, check 10:53. There I have the same problem. I will post the source code today (check description), so that you can check if that works for you.
@igotsomespace
@igotsomespace 5 жыл бұрын
@@Raphson Hi just checking to see if the source code was posted, I checked the description and the links do not lead to it. I really...really enjoyed this video, I hope you will have interest and time to make more videos like it. You are very skilled with Python programming : )
@Raphson
@Raphson 5 жыл бұрын
@@igotsomespace Hey! Thank you for your kind words! I did indeed forget to upload the code, thank you for reminding me! I will do it tonight! Promised! I will definitely make more videos like this as well! Cheers!
@roisanggung951
@roisanggung951 2 жыл бұрын
can i make it using google collabs?
@aswinjose9475
@aswinjose9475 4 жыл бұрын
Hey just couldn't understand why do we use load? Is it similar to image.getdata
@Raphson
@Raphson 4 жыл бұрын
You are right, that is maybe a redundant thing to do.
@aswinjose9475
@aswinjose9475 4 жыл бұрын
@@Raphson No, I'm just starting to code, couldn't really understand the difference, 😅. Thanks ☺.
@usertechgamer2310
@usertechgamer2310 4 жыл бұрын
how to fix too many values to unpack?
@Raphson
@Raphson 4 жыл бұрын
Try a different image. Apparently there are different formats within png.
@usertechgamer2310
@usertechgamer2310 4 жыл бұрын
@@Raphson it works, can I use your code to make a tkinter version of this?
@Raphson
@Raphson 4 жыл бұрын
@@usertechgamer2310 Definately dude! If you feel like it let me know how it turned out, always cool to see!
@HeroGamer1
@HeroGamer1 5 жыл бұрын
New sub love your content!
@youTubeViewer13
@youTubeViewer13 3 жыл бұрын
Awesome i love python very nice video. Very cool. i subscribe to your channel. excuse my english im French .
@user-zp9gb7tk7d
@user-zp9gb7tk7d 4 жыл бұрын
Hey, man. Could you tell me how to pass your code so that the resulting image is black and white, not color?
@user-zp9gb7tk7d
@user-zp9gb7tk7d 4 жыл бұрын
I really liked your video, very informative, but I'm new to programming and it was interesting. I tried to change it myself, but it didn't work :(
@Raphson
@Raphson 4 жыл бұрын
Alright I checked the code real quick because it is a while ago that I made that code, but I think you should change line 39, where it says "fill = (r, g, b)" to "fill = (h, h, h)". You can download my code from the description! Good luck, let me know if it doesn't work like you wanted!
@electrifywiz8491
@electrifywiz8491 3 жыл бұрын
im using pycharm to run this code.. but im not getting any output..
@Raphson
@Raphson 3 жыл бұрын
It should create files in the directory where your script runs.
@gmodandhl2experiments849
@gmodandhl2experiments849 2 жыл бұрын
help, my ver wont run and it's throwing a error
@Raphson
@Raphson 2 жыл бұрын
Ver?
@gmodandhl2experiments849
@gmodandhl2experiments849 2 жыл бұрын
@@Raphson Ver as in version
@gmodandhl2experiments849
@gmodandhl2experiments849 2 жыл бұрын
@@Raphson im also using 3.10.4 for python
@gmodandhl2experiments849
@gmodandhl2experiments849 2 жыл бұрын
@@Raphson help, can you help me out, I am still having problems, I have not gotten help and my friend is mad because I told him I would give him ASCII-ART, pls respond soon
@gmodandhl2experiments849
@gmodandhl2experiments849 2 жыл бұрын
@@Raphson Help please and thank you, I've been waiting for a reply
@rubenrcs
@rubenrcs 6 ай бұрын
Thanks !
@pablomora7880
@pablomora7880 4 жыл бұрын
Impressive! Man did u do it by your now? i mean did you check stackoverflow? im new to coding and these blows my mind! very abstract!
@Raphson
@Raphson 4 жыл бұрын
Hey man! I did use a bit of stack overflow to figure stuff out. Stack overflow is liturally the source of coding projects.
@pablomora7880
@pablomora7880 4 жыл бұрын
@@Raphson ANy tips for improving coding skills?
@Raphson
@Raphson 4 жыл бұрын
I think the best way to learn is to just do loads of random stuff! And always dare to ask everyone around you or on the internet if you get stuck!
@mofogamingttv9835
@mofogamingttv9835 2 жыл бұрын
I'm stuck on how Python is able to get the amount of pixels/dimensions
@Raphson
@Raphson 2 жыл бұрын
Send me a dm on insta, lets see if i can help!
@g2renders781
@g2renders781 4 жыл бұрын
I received "ValueError: too many values to unpack (expected 3)" @ 5:32 My Code: from PIL import Image, ImageDraw, ImageFont import math im = Image.open("C:/Users//Desktop/") width, height = im.size pix = im.load() print(width, height) for i in range(height): for j in range(width): r, g, b = pix[j, i] h = int(r/3 + g/3 + b/3) pix[j, i] = (h, h, h) im.save("output.png")
@Raphson
@Raphson 4 жыл бұрын
Okay so I ran your code and it worked perfectly fine man. I think it has to do with your input image, as I read in this thread: stackoverflow.com/questions/52666965/valueerror-too-many-values-to-unpack-expected-3-using-pil Try using another image man, maybe that helps. Let me know if you got it!
@qlmob5547
@qlmob5547 3 жыл бұрын
What is your IDE?
@Raphson
@Raphson 3 жыл бұрын
Atom!
@qlmob5547
@qlmob5547 3 жыл бұрын
@@Raphson thanks!
@jiriheistein4372
@jiriheistein4372 4 жыл бұрын
no module PIL found ???
@Raphson
@Raphson 4 жыл бұрын
You will have to install that using PIP. Check this answer: stackoverflow.com/questions/20060096/installing-pil-with-pip
@franklind.roosevel2863
@franklind.roosevel2863 3 жыл бұрын
i dont understand what [::-1] does you need to know i am very old
@Raphson
@Raphson 3 жыл бұрын
It stands for [start:stop:step], where start and stop are not filled in so the entire string is checked. Step is -1, so it steps backwards through the string! Hope this makes sense.
@franklind.roosevel2863
@franklind.roosevel2863 3 жыл бұрын
@@Raphson thanks
@lazizkhan1
@lazizkhan1 4 жыл бұрын
Who can write that all codes to here
@Raphson
@Raphson 3 жыл бұрын
Check raphsonite.github.io to download the code.
@ChrstphreCampbell
@ChrstphreCampbell 4 жыл бұрын
Like all of the ASCII generators that I’ve seen online, they invariably use a single character to represent a particular grayscale and I found that this creates a very blocky and rather ugly ASCII piece of art… Many years ago I wrote a program on my HP 48 that solves this by creating a string of characters starting with period And then comma and then ending with M & W, And then when I’m analyzing the source picture, I choose semi randomly from this list so that each character is within the range of the desired character density and the final artwork looks extremely smooth… ! If you’re interested in some examples look for “ASCII Art” on Flickr.… ! I have a version of this on _Scratch_ but unfortunately you need to download it to your own computer rather than use it on the Scratch platform because it’s just too complicated… ! scratch.mit.edu/projects/92282376 Oops ! I thought this might be easy to find, but apparently it was not ( !!! ) there’s quite a bit of stuff here that’s related to mailart so you may have to scroll down a bit to find some representative images.… ! www.flickr.com/gp/chrstphre/ip05Bj
@Raphson
@Raphson 4 жыл бұрын
Do you have a link to an image that was created using your method?
@ChrstphreCampbell
@ChrstphreCampbell 4 жыл бұрын
@@Raphson I added a link to the original text. '
@Raphson
@Raphson 4 жыл бұрын
So if I understand correctly, you introduce random noise to cover up sharp transitions? Looks good!
@ChrstphreCampbell
@ChrstphreCampbell 4 жыл бұрын
@@Raphson no; I am choosing a character from a range that represents approximately that grayscale so that a letter like an R in an S would be approximately equal and you could use either an M or a W for the darkest things.… likewise a period Might be either a period or a comma or even a semicolon, I think that there’s usually about six choices that can be chosen from…
@Raphson
@Raphson 4 жыл бұрын
Exactly. Thats cool! Not too hard to implement in my code either. In the getChar method, simply add a random number to the index between for example -3 and 3, and cap them to prevent using invalid indexes.
@modaryaghi
@modaryaghi 4 жыл бұрын
Oh, your coding skell is bad, though I loved the output.
@Raphson
@Raphson 4 жыл бұрын
I guess... thanks!?
@anugupta6834
@anugupta6834 2 жыл бұрын
lol u aslo copy paste programmer
@Raphson
@Raphson 2 жыл бұрын
Isn't every programmer?
@Usertrappedindatabase
@Usertrappedindatabase 3 жыл бұрын
How could you directly call the image file instead of changing the link within the source each time? like: asciipy image1.jpg new_outputnamehere.txt/jpg/md/whatever. or just cat output to terminal??
@Raphson
@Raphson 3 жыл бұрын
Hey man! Yeah you are looking for using command line arguments! I don't know the syntax from the top of my head but I'm sure if you google python command line arguments it will pop up! Cheers!
@orangejuice4245
@orangejuice4245 3 ай бұрын
Delete it now
@Raphson
@Raphson 3 ай бұрын
Oh, why?
Coding Challenge 166: ASCII Text Images
22:42
The Coding Train
Рет қаралды 1,1 МЛН
Making an ASCII Webcam with Python!
19:32
Scragg
Рет қаралды 8 М.
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
Python ASCII Pixel Art Converter  | Pygame  OpenCV |
9:48
Coder Space
Рет қаралды 24 М.
ASMR Programming - Spinning Cube - No Talking
20:45
Servet Gulnaroglu
Рет қаралды 4,3 МЛН
The Genius Way Computers Multiply Big Numbers
22:04
PurpleMind
Рет қаралды 192 М.
Convert Images to ASCII Art in Linux Terminal - jp2a
4:32
TechHut
Рет қаралды 55 М.
ASCII Art is BACK! (Generating ASCII Art Text from the Terminal)
8:47
ASCII Art Tips & Tricks
5:11
Creative Coding NYC
Рет қаралды 28 М.
Gabriel Santos - ASCII Art Techniques & Animation
19:53
Roguelike Celebration
Рет қаралды 10 М.