diff --git a/migrate.py b/migrate.py
index 435d815b..f8517df8 100644
--- a/migrate.py
+++ b/migrate.py
@@ -1086,10 +1086,10 @@ def migrate_sas():
file_name += "/" + str(r['id_photo']) + ".jpg"
file = File(open(file_name, "rb"))
- file.name = (str(r['id_photo']) + ".jpg").encode('utf-8')
+ file.name = str(r['id_photo']) + ".jpg"
p = Picture(
- name=(to_unicode(str(r['id_photo'])) + ".jpg").encode('utf-8'),
+ name=str(r['id_photo']) + ".jpg",
owner=user,
is_moderated=True,
is_folder=False,
diff --git a/sas/models.py b/sas/models.py
index 18483e61..a9f9cd22 100644
--- a/sas/models.py
+++ b/sas/models.py
@@ -17,9 +17,11 @@ class Picture(SithFile):
@property
def is_vertical(self):
- im = Image.open(BytesIO(self.file.read()))
- (w, h) = im.size
- return (w / h) < 1
+ with open(settings.MEDIA_ROOT + self.file.name).encode('utf-8'), 'rb') as f:
+ im = Image.open(BytesIO(f.read()))
+ (w, h) = im.size
+ return (w / h) < 1
+ return False
def can_be_edited_by(self, user):
return user.is_in_group(settings.SITH_SAS_ADMIN_GROUP_ID)
diff --git a/sas/templates/sas/album.jinja b/sas/templates/sas/album.jinja
index 2bf2f48a..e357e161 100644
--- a/sas/templates/sas/album.jinja
+++ b/sas/templates/sas/album.jinja
@@ -18,7 +18,7 @@
{% trans %}Edit{% endtrans %}