X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/5913c54d19b8f6775633176032161d49f9b2f1aa..040285e94b385dd57a003a4fe5b693c299fe921b:/src/cover/forms.py?ds=inline diff --git a/src/cover/forms.py b/src/cover/forms.py index 513bdefb..e5bc400d 100755 --- a/src/cover/forms.py +++ b/src/cover/forms.py @@ -3,7 +3,7 @@ # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # -from StringIO import StringIO +from io import BytesIO from django import forms from django.conf import settings @@ -18,6 +18,7 @@ from cover.utils import get_flickr_data, FlickrError, URLOpener class ImageAddForm(forms.ModelForm): class Meta: model = Image + exclude = [] def __init__(self, *args, **kwargs): super(ImageAddForm, self).__init__(*args, **kwargs) @@ -54,7 +55,7 @@ class ImageAddForm(forms.ModelForm): raise forms.ValidationError(ugettext('No image specified')) if download_url: image_data = URLOpener().open(download_url).read() - width, height = PILImage.open(StringIO(image_data)).size + width, height = PILImage.open(BytesIO(image_data)).size else: width, height = PILImage.open(uploaded_file.file).size min_width, min_height = settings.MIN_COVER_SIZE