Daniel Brötzmann pushed to branch master at gajim / gajim
Commits:
-
ef7284fe
by wurstsalat at 2021-12-12T22:51:53+01:00
1 changed file:
Changes:
| ... | ... | @@ -204,11 +204,16 @@ def create_thumbnail_with_pil(data: bytes, size: int) -> Optional[bytes]: |
| 204 | 204 |
if image.format == 'GIF' and image.n_frames > 1:
|
| 205 | 205 |
resize_gif(image, output_file, (size, size))
|
| 206 | 206 |
else:
|
| 207 |
- image.thumbnail((size, size))
|
|
| 208 |
- image.save(output_file,
|
|
| 209 |
- format=image.format,
|
|
| 210 |
- exif=image.info.get('exif', b''),
|
|
| 211 |
- optimize=True)
|
|
| 207 |
+ try:
|
|
| 208 |
+ image.thumbnail((size, size))
|
|
| 209 |
+ image.save(
|
|
| 210 |
+ output_file,
|
|
| 211 |
+ format=image.format,
|
|
| 212 |
+ exif=image.info.get('exif', b''),
|
|
| 213 |
+ optimize=True)
|
|
| 214 |
+ except OSError as error:
|
|
| 215 |
+ log.warning('saving pil thumbnail failed: %s', error)
|
|
| 216 |
+ return None
|
|
| 212 | 217 |
|
| 213 | 218 |
bytes_ = output_file.getvalue()
|
| 214 | 219 |
|