我有一个巨大的图像数据,我想用python中的特定大小在循环中自动调整它的大小

我有一个巨大的图像数据,我想用python中的特定大小在循环中自动调整它的大小,python,image,for-loop,crop,image-resizing,Python,Image,For Loop,Crop,Image Resizing,我有这个代码,但我不能把它放在一个循环中: 从PIL导入图像 # Opens a image in RGB mode im = Image.open(r"imagPath.png") # Setting the points for cropped image left = 155 top = 65 right = 360 bottom = 270 # Cropped image of above dimension # (It will not change o

我有这个代码,但我不能把它放在一个循环中: 从PIL导入图像

# Opens a image in RGB mode 
im = Image.open(r"imagPath.png") 

# Setting the points for cropped image 
left = 155
top = 65
right = 360
bottom = 270

# Cropped image of above dimension 
# (It will not change orginal image) 
im1 = im.crop((left, top, right, bottom)) 



# Shows the image in image viewer 
im1.show() 

它可以工作,但我希望它在for循环中读取文件夹中的所有图像

使用
os.listdir
列出文件夹中的所有图像,然后您可以对它们进行迭代。

什么阻止您将其放入循环中?