user149433
user149433

Reputation:

How to sort images into folders, based on resolution?

Background: I've got a folder full of saved desktop pictures. I'd like to put them into folders, based on their resolution - 1024x768, etc. Creating the folders on the fly is a bonus. Currently, the images are all in a folder, but some of them are in sub-folders. I can merge them by hand, if that makes things easier.

I'm using Mac OS X, but I'm not opposed to installing extra apps to accomplish this (MacPorts?), or even using another OS (I've got Windows XP, Windows Vista, and Ubuntu 9 setup right now within VMWare).

Any help would be appreciated! Thank you!

Upvotes: 0

Views: 2360

Answers (1)

Meredith L. Patterson
Meredith L. Patterson

Reputation: 4911

If you speak Python, the Python Imaging Library should do the trick.

import Image, os
for filename in os.listdir("/path/to/images"):
    image = Image.open(filename)

and from there, you can sort your images based on the size member, which is a (width, height) tuple.

Upvotes: 1

Related Questions