-3

I've some folders with about 200 images and I'd like to highlight the images with a size not multiple of 2.

Is there an efficient way of doing so?

Best Regards!

cyprieng
  • 706
  • 6
  • 16
  • 6
    What does it mean for an image to be a multiple of 2? – khelwood Feb 28 '17 at 13:33
  • You can match all filenames, and then open with an image library and find the dimensions, and print those which are multiples of 2. – Peter Wood Feb 28 '17 at 13:41
  • khelwood, I mean 2x2, 4x4, 8x8, ... 256 x 256 and variations as 64 x 128 , If an image is for instance, 127x63, I'd like to see it highlighted so that I can fix the mistake. Thanks for the answer Peter wood, I'll give it a try. – kyle_butler Mar 01 '17 at 22:54

1 Answers1

0

Here is a Python script that print all images that have a size which is not a multiple of 2. It simply finds all images and use PIL to get the dimension.

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)
cyprieng
  • 706
  • 6
  • 16
  • cyprieng, that you very much! It is far beyound what i can code currently, so I'm trying to understand each line. I can't thank you enough! Best regards! – kyle_butler Mar 03 '17 at 20:39