Only calculate aperture if fnumber is provided

This commit is contained in:
Joar Wandborg 2013-05-20 00:46:29 +02:00
parent 907bba318a
commit 1b6a2b85e1

View File

@ -254,16 +254,15 @@ class MediaEntryMixin(GenerateSlugMixin):
'%Y:%m:%d %H:%M:%S').date() '%Y:%m:%d %H:%M:%S').date()
taken = takendate.strftime('%B %d %Y') taken = takendate.strftime('%B %d %Y')
fnum = None aperture = None
if 'EXIF FNumber' in exif_all: if 'EXIF FNumber' in exif_all:
fnum = str(exif_all['EXIF FNumber']['printable']).split('/') fnum = str(exif_all['EXIF FNumber']['printable']).split('/')
# calculate aperture # calculate aperture
aperture = None if len(fnum) == 2:
if len(fnum) == 2: aperture = "f/%.1f" % (float(fnum[0])/float(fnum[1]))
aperture = "f/%.1f" % (float(fnum[0])/float(fnum[1])) elif fnum[0] != 'None':
elif fnum[0] != 'None': aperture = "f/%s" % (fnum[0])
aperture = "f/%s" % (fnum[0])
return { return {
"Camera" : exif_all['Image Model']['printable'], "Camera" : exif_all['Image Model']['printable'],