python 批量输出图像的尺寸大小及模式

file_path = './example/images/'
i = 0
for filename in os.listdir(file_path):
    img = Image.open(file_path + filename)
    mod = img.mode
    h,w = img.size
    print(filename,h,w,mod)    # (int(h/4),int(w/4)

    #if h % 448 != 0 or w % 448 != 0:  #可根据尺寸判断输出不满足要求的图像
    #    print(filename,h,w,mod)    # (int(h/4),int(w/4)
     #   i = i + 1
print(i)

猜你喜欢

转载自blog.csdn.net/weixin_42535423/article/details/121888763