Reputation: 21
I am trying to print an image with Python (I use Thonny).
from PIL import Image, ImageDraw
import numpy as np
image_entrée = Image.open("Lenna.png")
image = np.asarray(image_entrée)
nb_lignes,nb_colonnes,_ = image.shape
image_sortie = np.copy(image)
Image.fromarray(image).save("image_entree.png")
Image.fromarray(image_sortie).save("image_sortie.png")
This code is coming from a website and I don't understand where I have to put my image. I tried to change the file name and the image name but nothing changes. It says that it can not find Lenna.png In which file do I have to put my .png image ?
Thank you a lot for the time you will give me :)
Upvotes: 0
Views: 493
Reputation: 3158
program is looking for "Lenna.png" in the same directory where your python program is, one way is to copy Lenna.png
or any other image you want to use to put in the same folder where your .py program is. the other way is give it as a path my_file_path=r"/Users/SimpleApp/Downloads/my_picture.png"
and then use
image_entrée = Image.open(my_file_path)
Upvotes: 1