element-hq / element-hq/synapse
Thumbnailer.py throws "OSError: image file is truncated"
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 600
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 51
Description
This issue has been migrated from [#9476](https://github.com/matrix-org/synapse/issues/9476).
---
### Description
I get this error when `thumbnailer.py` works:
```
2021-02-24 09:25:59,850 - synapse.http.server - 91 - ERROR - GET-9897 - Failed handle request via 'ThumbnailResource':
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/synapse/http/server.py", line 252, in _async_render_wrapper
callback_return = await self._async_render(request)
File "/usr/local/lib/python3.8/site-packages/synapse/http/server.py", line 280, in _async_render
callback_return = await raw_callback_return
File "/usr/local/lib/python3.8/site-packages/synapse/rest/media/v1/thumbnail_resource.py", line 70, in _async_render_GET
await self._select_or_generate_local_thumbnail(
File "/usr/local/lib/python3.8/site-packages/synapse/rest/media/v1/thumbnail_resource.py", line 170, in _select_or_generate_local_thumbnail
file_path = await self.media_repo.generate_local_exact_thumbnail(
File "/usr/local/lib/python3.8/site-packages/synapse/rest/media/v1/media_repository.py", line 523, in generate_local_exact_thumbnail
t_byte_source = await defer_to_thread(
File "/usr/local/lib/python3.8/site-packages/twisted/python/threadpool.py", line 250, in inContext
result = inContext.theWork()
File "/usr/local/lib/python3.8/site-packages/twisted/python/threadpool.py", line 266, in
inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
File "/usr/local/lib/python3.8/site-packages/twisted/python/context.py", line 122, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/usr/local/lib/python3.8/site-packages/twisted/python/context.py", line 85, in callWithContext
return func(*args,**kw)
File "/usr/local/lib/python3.8/site-packages/synapse/logging/context.py", line 843, in g
return f(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/synapse/rest/media/v1/media_repository.py", line 494, in _generate_thumbnail
return thumbnailer.scale(t_width, t_height, t_type)
File "/usr/local/lib/python3.8/site-packages/synapse/rest/media/v1/thumbnailer.py", line 110, in scale
scaled = self._resize(width, height)
File "/usr/local/lib/python3.8/site-packages/synapse/rest/media/v1/thumbnailer.py", line 102, in _resize
return self.image.resize((width, height), Image.ANTIALIAS)
File "/usr/local/lib/python3.8/site-packages/PIL/Image.py", line 1906, in resize
return self.copy()
File "/usr/local/lib/python3.8/site-packages/PIL/Image.py", line 1117, in copy
self.load()
File "/usr/local/lib/python3.8/site-packages/PIL/ImageFile.py", line 259, in load
raise OSError(
OSError: image file is truncated (49 bytes not processed)
```
I think this is the error: https://stackoverflow.com/questions/60584155/oserror-image-file-is-truncated
- **Version**: Homeserver version: Synapse 1.27.0
Contributor guide
Assessment
This issue has not been assessed yet.