Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Pillow 10.0.0 slows down images uploading speeds #15937

Closed
Rud356 opened this issue Jul 13, 2023 · 2 comments
Closed

Pillow 10.0.0 slows down images uploading speeds #15937

Rud356 opened this issue Jul 13, 2023 · 2 comments

Comments

@Rud356
Copy link

Rud356 commented Jul 13, 2023

Description

Pillow dependency should be pinned or specified to latest version around 9.x.x in order to fix this problem, because 10.0.0 released not long ago made changes that aren't backward compatible. Alternatively it is possible to make fix just by checking version of package and making constants have same names as before.

Small part of logs listed below.
Traceback:

File: ".../synapse/media/thumbnailer.py", line 134, in _resize
    return self.image.resize((width, height), Image.ANTIALIAS)
AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'

Steps to reproduce

  • Install synapse server from source and configure normally on any supported version of python
  • Send image and get it to make thumbnail for chat picture or send picture in chat

Homeserver

Personal homeserver

Synapse Version

1.87.0

Installation Method

pip (from PyPI)

Database

postgresql

Workers

Multiple workers

Platform

Raspbian x64, raspberry pi, python 3.9, nginx, redis, postgresql

Configuration

No response

Relevant log output

2023-07-11 11:58:59,889 - synapse.http.server - 133 - ERROR - GET-11192 - Failed handle request via 'PreviewUrlResource': <XForwardedForRequest at 0x7f9808be80 method='GET' uri='/_matrix/media/r0/preview_url?url=https%3A%2F%2Fgithub.jparrowsec.cn%2Fmaunium%2Fstickerpicker%2Fwiki%2FEnabling-the-widget&ts=1679845260000' clientproto='HTTP/1.0' site='8008'>
Traceback (most recent call last):
  File ".../synapse/env/lib/python3.9/site-packages/twisted/internet/defer.py", line 1693, in _inlineCallbacks
    result = context.run(
  File ".../synapse/env/lib/python3.9/site-packages/twisted/python/failure.py", line 518, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File ".../synapse/env/lib/python3.9/site-packages/synapse/media/url_previewer.py", line 330, in _do_preview
    await self._precache_image_url(user, media_info, og)
  File ".../synapse/env/lib/python3.9/site-packages/synapse/media/url_previewer.py", line 678, in _precache_image_url
    dims = await self.media_repo._generate_thumbnails(
  File ".../synapse/env/lib/python3.9/site-packages/synapse/media/media_repository.py", line 797, in _generate_thumbnails
    t_byte_source = await defer_to_thread(
  File ".../synapse/env/lib/python3.9/site-packages/twisted/python/threadpool.py", line 244, in inContext
    result = inContext.theWork()  # type: ignore[attr-defined]
  File ".../synapse/env/lib/python3.9/site-packages/twisted/python/threadpool.py", line 260, in <lambda>
    inContext.theWork = lambda: context.call(  # type: ignore[attr-defined]
  File ".../synapse/env/lib/python3.9/site-packages/twisted/python/context.py", line 117, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File ".../synapse/env/lib/python3.9/site-packages/twisted/python/context.py", line 82, in callWithContext
    return func(*args, **kw)
  File ".../synapse/env/lib/python3.9/site-packages/synapse/logging/context.py", line 969, in g
    return f(*args, **kwargs)
  File ".../synapse/env/lib/python3.9/site-packages/synapse/media/thumbnailer.py", line 172, in crop    with self._resize(scaled_width, scaled_height) as scaled_image:
  File ".../synapse/env/lib/python3.9/site-packages/synapse/media/thumbnailer.py", line 134, in _resize
    return self.image.resize((width, height), Image.ANTIALIAS)
AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'

Anything else that would be useful to know?

No response

@dklimpel
Copy link
Contributor

This should be fixed by #15876 and is duplicate to #15873

@Rud356
Copy link
Author

Rud356 commented Jul 14, 2023

This should be fixed by #15876 and is duplicate to #15873

Okay, then I'll close issue.

@Rud356 Rud356 closed this as completed Jul 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants