I wouldl like to query a date of when a photo was taken.. how may I do that?

Recommended Answers

All 3 Replies

It can be as simple as this ...

import os
import time

# pick a file you have in the working directory
filename = "beachball.jpg"

# show file creation time
print( time.ctime(os.path.getctime(filename)) )

Keep in mind that vegaseat's solution will only show you when the photo was created in the filesystem. If you took the photo on a digital camera and then put it on your computer three days later, the creation date would not be the time the picture was taken.

A lot of cameras put information in the header of the jpeg file itself that might contain the date and time the photo was taken. I did a google search for "python jpeg metadata" and found a lot of results so you might be able to find a library to help you.

commented: good info +2

Thanks for the help guys.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.