load truncated images
This commit is contained in:
parent
c27ddd4170
commit
fd6bba5004
1 changed files with 4 additions and 2 deletions
|
@ -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,6 +70,7 @@ 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'):
|
||||
if source.mode != 'RGB':
|
||||
source = source.convert('RGB')
|
||||
source_width = source.size[0]
|
||||
source_height = source.size[1]
|
||||
|
|
Loading…
Reference in a new issue