Private
Public Access
1
0

bug fix strava & image

Detect existing workouts on Strava threw an error
Image upload sometimes gave a KeyError
This commit is contained in:
Sander Roosendaal
2018-07-23 09:07:25 +02:00
parent 78cc8b86d5
commit e70c477f82
2 changed files with 18 additions and 10 deletions

View File

@@ -5,11 +5,11 @@ import hashlib
from django.core.exceptions import ValidationError
def format_pace_tick(x,pos=None):
min=int(x/60)
sec=int(x-min*60.)
minu=int(x/60)
sec=int(x-minu*60.)
sec_str=str(sec).zfill(2)
template='%d:%s'
return template % (min,sec_str)
return template % (minu,sec_str)
def format_time_tick(x,pos=None):
hour=int(x/3600)
@@ -109,12 +109,15 @@ def handle_uploaded_image(i):
hsize = int((float(image.size[1])*float(wpercent)))
image = image.resize((basewidth,hsize), Image.ANTIALIAS)
if exif[orientation] == 3:
image=image.rotate(180, expand=True)
elif exif[orientation] == 6:
image=image.rotate(270, expand=True)
elif exif[orientation] == 8:
image=image.rotate(90, expand=True)
try:
if exif[orientation] == 3:
image=image.rotate(180, expand=True)
elif exif[orientation] == 6:
image=image.rotate(270, expand=True)
elif exif[orientation] == 8:
image=image.rotate(90, expand=True)
except KeyError:
pass
filename = hashlib.md5(imagefile.getvalue()).hexdigest()+'.jpg'