# 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
class ImageAddForm(forms.ModelForm):
class Meta:
model = Image
+ exclude = []
def __init__(self, *args, **kwargs):
super(ImageAddForm, self).__init__(*args, **kwargs)
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