Can you guys help me take a look?What's the problem
The code I wrote below
#Import os module
import os
#Import image package
import shutil
from PIL import Image
path = "D:\python\gaizi"
save = "D:/python/abc_666"
file_list = os.listdir(path)
for file in file_list:
imgPath = os.path.join(path, file)
img = Image.open(imgPath)
imgSize = img.size
print(imgSize, imgPath)
minSize = min(imgSize)
if minSize >= 320:
images_min = os.path.join(save, file) + ".jpg"
shutil.copy(imgPath, images_min)
img.close()
print(minSize)
if name == "main":
if not os.path.exists(save):
os.makedirs(save)
print(file)
The last error is:
C:\ProgramData\Anaconda3\python.exe D:/code/Test/test1/imgsize.py
Traceback (most recent call last):
File "D:/code/Test/test1/imgsize.py", line 13, in
img = Image.open("imgPath")
File "C:\ProgramData\Anaconda3\lib\site-packages\PIL\Image.py", line 3092, in open
fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'imgPath'