avoid rewriting cover cache if one resize fails
This commit is contained in:
parent
0f1cd9662d
commit
84259fb0c4
2 changed files with 31 additions and 10 deletions
|
|
@ -66,14 +66,17 @@ def get_by_key(objects, key, value):
|
|||
def get_by_id(objects, id):
|
||||
return get_by_key(objects, 'id', id)
|
||||
|
||||
def is_svg(data):
|
||||
return data and b'<svg' in data[:256]
|
||||
|
||||
def resize_image(data, width=None, size=None):
|
||||
if isinstance(data, bytes):
|
||||
data = BytesIO(data)
|
||||
else:
|
||||
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 not in ('1', 'CMYK', 'L', 'RGB', 'RGBA', 'RGBX', 'YCbCr'):
|
||||
source = source.convert('RGB')
|
||||
source_width = source.size[0]
|
||||
source_height = source.size[1]
|
||||
if size:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue