Ver código fonte

Fix issue with determining image format.

refactor
Syfaro 8 meses atrás
pai
commit
23ac6c5cdc
1 arquivos alterados com 7 adições e 12 exclusões
  1. +7
    -12
      src/submission.py

+ 7
- 12
src/submission.py Ver arquivo

@@ -82,27 +82,22 @@ class Submission(object):
"""Resize image to specified height and width with antialiasing"""
image = Image.open(self.image_bytes)

print('attempting image resize')

if image.height <= height and image.width <= width:
self.image_bytes.seek(0)
return self.image_filename, self.image_bytes

# need to get extension from name due to bytes not having a name
# when resizing this causes an issue as it cannot determine type
if image.format:
f = image.format
else:
f = None

if not image.mode.startswith('RGB'):
image = image.convert('RGBA') # Everything works better as RGB

image.thumbnail((height, width), Image.ANTIALIAS)

# need to get extension from name due to bytes not having a name
# when resizing this causes an issue as it cannot determine type
try:
f = self.image_filename.split('.')[-1]
except:
if image.format:
f = image.format
else:
f = None

breadcrumbs.record(message=f'Attempting to resize image with extension {f}', category='furryapp', level='info')

resized_image = BytesIO()


Carregando…
Cancelar
Salvar