diff --git a/rowers/models.py b/rowers/models.py
index 672b0445..6bb2c91e 100644
--- a/rowers/models.py
+++ b/rowers/models.py
@@ -584,6 +584,8 @@ class GraphImage(models.Model):
filename = models.CharField(default='',max_length=150,blank=True,null=True)
creationdatetime = models.DateTimeField()
workout = models.ForeignKey(Workout)
+ width = models.IntegerField(default=1200)
+ height = models.IntegerField(default=600)
def __str__(self):
return self.filename
diff --git a/rowers/templates/show_graph.html b/rowers/templates/show_graph.html
index 368e09f4..d6064e42 100644
--- a/rowers/templates/show_graph.html
+++ b/rowers/templates/show_graph.html
@@ -9,8 +9,12 @@
{% block og_description %}{{ workout.name }}
{{ workout.date }} - {{ workout.distance }}m - {{ workout.duration |durationprint:"%H:%M:%S.%f" }}{% endblock %}
{% block og_image %}
-
+
+
+
+
+
{% endblock %}
{% block content %}
{{ workout.name }}
diff --git a/rowers/templates/workout_view.html b/rowers/templates/workout_view.html
index c58fe3f2..c364ed3d 100644
--- a/rowers/templates/workout_view.html
+++ b/rowers/templates/workout_view.html
@@ -14,7 +14,11 @@
{% block og_image %}
{% for graph in graphs1 %}
+
+
+
+
{% endfor %}
{% endblock %}
{% block image_src %}
diff --git a/rowers/uploads.py b/rowers/uploads.py
index d5405a60..578d1807 100644
--- a/rowers/uploads.py
+++ b/rowers/uploads.py
@@ -10,6 +10,8 @@ from rowers.tasks import (
from rowers.models import GraphImage
+from PIL import Image
+
import numpy as np
import yaml
import argparse
@@ -181,10 +183,16 @@ def make_plot(r,w,f1,f2,plottype,title,imagename='',plotnr=0):
title,hrpwrdata,
plotnr,imagename)
-
+ try:
+ width,height = Image.open(fullpathimagename).size
+ except:
+ width = 1200
+ height = 600
+
i = GraphImage(workout=w,
creationdatetime=timezone.now(),
- filename=fullpathimagename)
+ filename=fullpathimagename,
+ width=width,height=height)
i.save()
return i.id
diff --git a/rowers/views.py b/rowers/views.py
index 349feb5d..074b5b65 100644
--- a/rowers/views.py
+++ b/rowers/views.py
@@ -8,6 +8,7 @@ import pytz
import operator
import warnings
import urllib
+from PIL import Image
from numbers import Number
from django.views.generic.base import TemplateView
from django.db.models import Q
@@ -4594,6 +4595,15 @@ def workout_view(request,id=0):
raise Http404("Not allowed to view this workout")
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
+ for i in g:
+ try:
+ width,height = Image.open(i.filename).size
+ i.width = width
+ i.height = height
+ i.save()
+ except:
+ pass
+
r = Rower.objects.get(id=row.user.id)
u = User.objects.get(id=r.user.id)
@@ -5229,6 +5239,15 @@ def workout_geeky_view(request,id=0,message="",successmessage=""):
form = WorkoutForm(instance=row)
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
+ for i in g:
+ try:
+ width,height = Image.open(i.filename).size
+ i.width = width
+ i.height = height
+ i.save()
+ except:
+ pass
+
# check if user is owner of this workout
if (checkworkoutuser(request.user,row)==False):
@@ -5670,6 +5689,15 @@ def workout_advanced_view(request,id=0,message="",successmessage=""):
raise Http404("Workout doesn't exist")
form = WorkoutForm(instance=row)
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
+ for i in g:
+ try:
+ width,height = Image.open(i.filename).size
+ i.width = width
+ i.height = height
+ i.save()
+ except:
+ pass
+
# check if user is owner of this workout
if (checkworkoutuser(request.user,row)==False):
@@ -6113,6 +6141,15 @@ def workout_export_view(request,id=0, message="", successmessage=""):
form = WorkoutForm(instance=row)
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
+ for i in g:
+ try:
+ width,height = Image.open(i.filename).size
+ i.width = width
+ i.height = height
+ i.save()
+ except:
+ pass
+
# check if user is owner of this workout
if (checkworkoutuser(request.user,row)==False):
@@ -6253,6 +6290,15 @@ def workout_comment_view(request,id=0):
form = WorkoutCommentForm()
g = GraphImage.objects.filter(workout=w).order_by("-creationdatetime")
+ for i in g:
+ try:
+ width,height = Image.open(i.filename).size
+ i.width = width
+ i.height = height
+ i.save()
+ except:
+ pass
+
if (len(g)<=3):
return render(request,
@@ -6372,6 +6418,16 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
raise Http404("Workout doesn't exist")
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
+ for i in g:
+ try:
+ width,height = Image.open(i.filename).size
+ i.width = width
+ i.height = height
+ i.save()
+ except:
+ pass
+
+
# check if user is owner of this workout
comments = WorkoutComment.objects.filter(workout=row)
@@ -6593,6 +6649,15 @@ def workout_edit_view_navionics(request,id=0,message="",successmessage=""):
raise Http404("Workout doesn't exist")
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
+ for i in g:
+ try:
+ width,height = Image.open(i.filename).size
+ i.width = width
+ i.height = height
+ i.save()
+ except:
+ pass
+
# check if user is owner of this workout
comments = WorkoutComment.objects.filter(workout=row)
@@ -7774,6 +7839,14 @@ def graphs_view(request):
def graph_show_view(request,id):
try:
g = GraphImage.objects.get(id=id)
+ try:
+ width,height = Image.open(g.filename).size
+ g.width = width
+ g.height = height
+ g.save()
+ except:
+ pass
+
w = Workout.objects.get(id=g.workout.id)
r = Rower.objects.get(id=w.user.id)