How to add image in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to add image in python

From starting

15th Jan 2020, 9:00 AM
Ayush Pandey
Ayush Pandey - avatar
7 Answers
+ 5
from PIL import Image img = Image.open('image.jpg') img.show()
15th Jan 2020, 11:50 AM
Roman Ignatev
Roman Ignatev - avatar
+ 2
you have to use a Gui library like pygame,... it's not possible in sololearn. read about pygame and try it on your computer.
15th Jan 2020, 9:22 AM
Bahhaⵣ
Bahhaⵣ - avatar
+ 2
Mirielle🐶 right, if you check my answer I said pygame and ... for other possibilities. I suggested pygame for simplicity, I'm not saying Pillow is not used in the solution. the real issue here is the poster, he is not very accurate about what he needs. if he just needs to open an image and show it with the system image viewer or show it in a window, sure pillow is the way to go. but if he needs to put it (add it) in a window with other components, buttons, text fields... he would need some gui library not pygame necessarily, it's just a suggestion. and yes that library will use pillow. by manipulate I meant process images in all kinds of ways. I used PIL to write image filters for GIMP, before PIL development was stalled and moved to Pillow as a fork. funny that you are talking about [behind the scenes and the use everywhere] remember when I tried to say that about socket in python networking. but you were denying it, good times 😃
15th Jan 2020, 7:15 PM
Bahhaⵣ
Bahhaⵣ - avatar
+ 2
Mirielle🐶 I agree with you, what i'm saying is there are things you can do with PIL alone and things that you need another library to complement PIL. if you need to make a gui window with buttons and events and add an image somewhere in the window you need Gui library, yes it will include PIL or OpenCV... the post title says add image to Python, and it depends on what the user means by that. why use pygame or any other gui because it provides events and a window to interact with.
15th Jan 2020, 9:16 PM
Bahhaⵣ
Bahhaⵣ - avatar
+ 1
Mirielle🐶 I believe Op is asking to add image to Python like in html <img> which requires graphics. PIL and PILLOW, are used to manipulate images not for user interface.
15th Jan 2020, 10:08 AM
Bahhaⵣ
Bahhaⵣ - avatar
0
Mirielle🐶 how did you interpret "add image to Python"? for me "add image" means insert image into a window, how? using a library that will create that window. PIL cannot create that alone.
15th Jan 2020, 9:25 PM
Bahhaⵣ
Bahhaⵣ - avatar
0
But why it is saying that module not found https://www.sololearn.com/discuss/2134584/?ref=app
17th Jan 2020, 12:15 AM
Ayush Pandey
Ayush Pandey - avatar