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.
@Raphson2 жыл бұрын
Well found, sir!
@nomadautodidact5 күн бұрын
Fantastic tutorial bro!!! Perfectly edited!!
@jacksonbernardo6703 жыл бұрын
Dude this is awesome! I cannoy believe that this program was made in Python :0
@notyrants5078 ай бұрын
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!
@Raphson8 ай бұрын
Happy to help!
@csbluechip4 жыл бұрын
Awesome ... It's like listening to the inside of my head while I'm coding LOL
@TSPTHUNDER4 жыл бұрын
till 5:21 .....i write and when i run the black and white image is not generated ...i use pycharm....plz help
@TSPTHUNDER4 жыл бұрын
and it says 'method' object is not subscriptable at r, g, b = pix[j, i] line
@Raphson4 жыл бұрын
Could you first try to use a different image? Some PNG's apparently have a different structure or so, that might cause this.
@TSPTHUNDER4 жыл бұрын
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...
@Raphson4 жыл бұрын
Haha okay man I have time tonight to check it, okay? I'll be back.
@abhradeepdey90543 жыл бұрын
Tyvm, i actually learnt some concepts of image processing
@blockchaindomain3 жыл бұрын
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]
@Raphson3 жыл бұрын
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.
@blockchaindomain3 жыл бұрын
That's okay I learned a lot from your video and I appreciate you making this easy to understand
@hypercsgokl62202 жыл бұрын
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
@PaulJoshi4 жыл бұрын
Dude this is Gold!!❤❤
@GeneralBlorp3 жыл бұрын
Great job!
@richardfeynman38564 жыл бұрын
Круто, мужик! Я очень впечатлён. Very cool man! I'm impressed.
@Raphson4 жыл бұрын
Thank you!
@mageshkumar33183 жыл бұрын
i am running this in visual studio code idk where my out put is
@vanmanhtran48133 жыл бұрын
Thank you, guy! But I have one problem: how to print output on terminal instead of render png file? Thank again.
@Raphson3 жыл бұрын
Simply use pythons print command!
@vanmanhtran48133 жыл бұрын
@@Raphson I have no idea in order to print with file png :(( pls assist me
@fahadkhan-qz7nz3 жыл бұрын
Bro, i love the way u code
@Raphson3 жыл бұрын
Thanks man!
@barteksful3 жыл бұрын
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?
@Raphson3 жыл бұрын
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.
@joedew41833 жыл бұрын
**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
@henrykidman43643 жыл бұрын
how did you fix it ?
@S_whoelse2 жыл бұрын
I installed Pillow but its telling me that there isnt a module named "PIL"?
@Raphson2 жыл бұрын
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!
@pranavsridhar19023 жыл бұрын
Hai,how to copy the path of the font?
@kwkwbwjsj5 жыл бұрын
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
@Raphson5 жыл бұрын
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.
@igotsomespace5 жыл бұрын
@@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 : )
@Raphson5 жыл бұрын
@@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!
@roisanggung9512 жыл бұрын
can i make it using google collabs?
@aswinjose94754 жыл бұрын
Hey just couldn't understand why do we use load? Is it similar to image.getdata
@Raphson4 жыл бұрын
You are right, that is maybe a redundant thing to do.
@aswinjose94754 жыл бұрын
@@Raphson No, I'm just starting to code, couldn't really understand the difference, 😅. Thanks ☺.
@usertechgamer23104 жыл бұрын
how to fix too many values to unpack?
@Raphson4 жыл бұрын
Try a different image. Apparently there are different formats within png.
@usertechgamer23104 жыл бұрын
@@Raphson it works, can I use your code to make a tkinter version of this?
@Raphson4 жыл бұрын
@@usertechgamer2310 Definately dude! If you feel like it let me know how it turned out, always cool to see!
@HeroGamer15 жыл бұрын
New sub love your content!
@youTubeViewer133 жыл бұрын
Awesome i love python very nice video. Very cool. i subscribe to your channel. excuse my english im French .
@user-zp9gb7tk7d4 жыл бұрын
Hey, man. Could you tell me how to pass your code so that the resulting image is black and white, not color?
@user-zp9gb7tk7d4 жыл бұрын
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 :(
@Raphson4 жыл бұрын
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!
@electrifywiz84913 жыл бұрын
im using pycharm to run this code.. but im not getting any output..
@Raphson3 жыл бұрын
It should create files in the directory where your script runs.
@gmodandhl2experiments8492 жыл бұрын
help, my ver wont run and it's throwing a error
@Raphson2 жыл бұрын
Ver?
@gmodandhl2experiments8492 жыл бұрын
@@Raphson Ver as in version
@gmodandhl2experiments8492 жыл бұрын
@@Raphson im also using 3.10.4 for python
@gmodandhl2experiments8492 жыл бұрын
@@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
@gmodandhl2experiments8492 жыл бұрын
@@Raphson Help please and thank you, I've been waiting for a reply
@rubenrcs6 ай бұрын
Thanks !
@pablomora78804 жыл бұрын
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!
@Raphson4 жыл бұрын
Hey man! I did use a bit of stack overflow to figure stuff out. Stack overflow is liturally the source of coding projects.
@pablomora78804 жыл бұрын
@@Raphson ANy tips for improving coding skills?
@Raphson4 жыл бұрын
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!
@mofogamingttv98352 жыл бұрын
I'm stuck on how Python is able to get the amount of pixels/dimensions
@Raphson2 жыл бұрын
Send me a dm on insta, lets see if i can help!
@g2renders7814 жыл бұрын
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")
@Raphson4 жыл бұрын
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!
@qlmob55473 жыл бұрын
What is your IDE?
@Raphson3 жыл бұрын
Atom!
@qlmob55473 жыл бұрын
@@Raphson thanks!
@jiriheistein43724 жыл бұрын
no module PIL found ???
@Raphson4 жыл бұрын
You will have to install that using PIP. Check this answer: stackoverflow.com/questions/20060096/installing-pil-with-pip
@franklind.roosevel28633 жыл бұрын
i dont understand what [::-1] does you need to know i am very old
@Raphson3 жыл бұрын
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.roosevel28633 жыл бұрын
@@Raphson thanks
@lazizkhan14 жыл бұрын
Who can write that all codes to here
@Raphson3 жыл бұрын
Check raphsonite.github.io to download the code.
@ChrstphreCampbell4 жыл бұрын
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
@Raphson4 жыл бұрын
Do you have a link to an image that was created using your method?
@ChrstphreCampbell4 жыл бұрын
@@Raphson I added a link to the original text. '
@Raphson4 жыл бұрын
So if I understand correctly, you introduce random noise to cover up sharp transitions? Looks good!
@ChrstphreCampbell4 жыл бұрын
@@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…
@Raphson4 жыл бұрын
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.
@modaryaghi4 жыл бұрын
Oh, your coding skell is bad, though I loved the output.
@Raphson4 жыл бұрын
I guess... thanks!?
@anugupta68342 жыл бұрын
lol u aslo copy paste programmer
@Raphson2 жыл бұрын
Isn't every programmer?
@Usertrappedindatabase3 жыл бұрын
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??
@Raphson3 жыл бұрын
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!