Merge remote-tracking branch 'refs/remotes/tryggvib/532-exif-creation-date'

Conflicts:
	mediagoblin/config_spec.ini
	mediagoblin/templates/mediagoblin/user_pages/media.html
This commit is contained in:
Christopher Allan Webber
2013-05-11 13:48:42 -05:00
3 changed files with 29 additions and 0 deletions

View File

@@ -44,6 +44,23 @@ class ImageData(Base):
gps_altitude = Column(Float)
gps_direction = Column(Float)
def get_original_date(self):
"""
Get the original date and time from the EXIF information. Returns
either a datetime object or None (if anything goes wrong)
"""
import datetime
try:
# Try wrapped around all since exif_all might be none,
# EXIF DateTimeOriginal or printable might not exist, or
# strptime might not be able to parse date correctly
exif_date = self.exif_all['EXIF DateTimeOriginal']['printable']
original_date = datetime.datetime.strptime(exif_date,
'%Y:%m:%d %H:%M:%S')
return original_date
except:
return None
DATA_MODEL = ImageData
MODELS = [ImageData]