如何在大小不超过2的特定文件夹中找到图像



我有一些文件夹,其中大约有200张图像,我想突出显示大小而不是2的尺寸的图像。

是否有一种有效的方法?

最好的问候!

这是一个python脚本,它打印所有具有大小的图像不是2个倍数。

import glob
from PIL import Image
# Get all images
image_path = 'PATH TO YOUR IMAGES'
images = glob.glob(image_path + '/**.png')  # Depending on your images extension
images_not_pair = []
# For all images open them with PIL and get the image size
for image in images:
    with Image.open(image) as im:
        width, height = im.size
        if width % 2 is not 0 or height % 2 is not 0:
            images_not_pair.append(image)
print(images_not_pair)

最新更新