load truncated images

This commit is contained in:
j 2019-01-01 00:19:55 +01:00
parent c27ddd4170
commit fd6bba5004
1 changed files with 4 additions and 2 deletions

View File

@ -4,7 +4,7 @@
from datetime import datetime
from io import StringIO, BytesIO
from PIL import Image
from PIL import Image, ImageFile
import base64
import hashlib
import json
@ -34,6 +34,7 @@ import logging
logging.getLogger('PIL').setLevel(logging.ERROR)
logger = logging.getLogger(__name__)
ImageFile.LOAD_TRUNCATED_IMAGES = True
ENCODING = 'base64'
def valid_olid(id):
@ -69,7 +70,8 @@ def resize_image(data, width=None, size=None):
data = StringIO(data)
source = Image.open(data)
#if source.mode not in ('1', 'CMYK', 'L', 'RGB', 'RGBA', 'RGBX', 'YCbCr'):
source = source.convert('RGB')
if source.mode != 'RGB':
source = source.convert('RGB')
source_width = source.size[0]
source_height = source.size[1]
if size: