Modifies EXIF section with Camera Info, display toggle and template styling

This commit is contained in:
Gabriel Saldana
2013-03-05 00:05:35 -06:00
committed by Joar Wandborg
parent b3566e1dc7
commit 420e1374d8
3 changed files with 139 additions and 3 deletions

View File

@@ -237,6 +237,33 @@ class MediaEntryMixin(GenerateSlugMixin):
label = re.sub('(.)([A-Z][a-z]+)', r'\1 \2', key)
yield label.replace('EXIF', '').replace('Image', ''), exif_all[key]
def exif_display_data_short(self):
"""Display a very short practical version of exif info"""
import time, datetime
if not self.media_data:
return
exif_all = self.media_data.get("exif_all")
# format date taken
takendate = datetime.datetime.strptime(
exif_all['Image DateTimeOriginal']['printable'],
'%Y:%m:%d %H:%M:%S').date()
taken = takendate.strftime('%B %d %Y')
fnum = str(exif_all['EXIF FNumber']['printable']).split('/')
# calculate aperture
if len(fnum) == 2:
aperture = "f/%.1f" % (float(fnum[0])/float(fnum[1]))
elif fnum[0] != 'None':
aperture = "f/%s" % (fnum[0])
else:
aperture = None
return {
"Camera" : exif_all['Image Model']['printable'],
"Exposure" : '%s sec' % exif_all['EXIF ExposureTime']['printable'],
"Aperture" : aperture,
"ISO" : exif_all['EXIF ISOSpeedRatings']['printable'],
"Focal Length" : '%s mm' % exif_all['EXIF FocalLength']['printable'],
"Date Taken" : taken,
}
class MediaCommentMixin(object):
@property