DEV Community

Cover image for Metadata based image filtering
Tushar Srivastava
Tushar Srivastava

Posted on

Metadata based image filtering

A few years ago, I went for a vacation with my friends ... bla bla bla ... and all the pictures from everyone's phones somehow landed in a single folder on my machine. For some reason I wanted them separate(I don't know why, it was a long time ago) and then what happened is why you're here reading this post.

Tools:

  • Python
  • PIL library
  • os library

Key functions:

  1. Use os.listdir to get the names of image files(requires split on . and check extension) in the directory.
  2. Function getCameraModel uses PIL.Image and returns the camera model of image.
  3. Function copy to copy that image file into the folder with name same as camera model (creates if doesn't exist).

Just put'em all together and you're good to go. Here's the gist.

and that's the story how python saved the day

Top comments (0)