summary refs log tree commit diff
path: root/synapse/rest/media/v1/thumbnailer.py (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Refactor media modules. (#15146)Patrick Cloke2023-02-271-221/+0
| | | | | | | * Removes the `v1` directory from `test.rest.media.v1`. * Moves the non-REST code from `synapse.rest.media.v1` to `synapse.media`. * Flatten the `v1` directory from `synapse.rest.media`, but leave compatiblity with 3rd party media repositories and spam checkers.
* Bump black from 22.12.0 to 23.1.0 (#15103)dependabot[bot]2023-02-221-1/+0
|
* Prefer `type(x) is int` to `isinstance(x, int)` (#14945)David Robertson2023-01-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Perfer `type(x) is int` to `isinstance(x, int)` This covered all additional instances I could see where `x` was user-controlled. The remaining cases are ``` $ rg -s 'isinstance.*[^_]int' tests/replication/_base.py 576: if isinstance(obj, int): synapse/util/caches/stream_change_cache.py 136: assert isinstance(stream_pos, int) 214: assert isinstance(stream_pos, int) 246: assert isinstance(stream_pos, int) 267: assert isinstance(stream_pos, int) synapse/replication/tcp/external_cache.py 133: if isinstance(result, int): synapse/metrics/__init__.py 100: if isinstance(calls, (int, float)): synapse/handlers/appservice.py 262: assert isinstance(new_token, int) synapse/config/_util.py 62: if isinstance(p, int): ``` which cover metrics, logic related to `jsonschema`, and replication and data streams. AFAICS these are all internal to Synapse * Changelog
* Remove redundant types from comments. (#14412)Patrick Cloke2022-11-161-2/+2
| | | | | | | Remove type hints from comments which have been added as Python type hints. This helps avoid drift between comments and reality, as well as removing redundant information. Also adds some missing type hints which were simple to fill in.
* Fix potential thumbnail memory leaks. (#12932)Erik Johnston2022-06-011-11/+60
|
* Fix mypy against latest pillow stubs (#12671)David Robertson2022-05-091-3/+3
|
* Fix error in thumbnail generation (#11288)Neeeflix2021-11-101-4/+4
| | | Signed-off-by: Jonas Zeunert <jonas@zeunert.org>
* Relax `ignore-missing-imports` for modules that have stubs now and update ↵David Robertson2021-10-081-4/+17
| | | | | | | | | | | | mypy (#11006) Updating mypy past version 0.9 means that third-party stubs are no-longer distributed with typeshed. See http://mypy-lang.blogspot.com/2021/06/mypy-0900-released.html for details. We therefore pull in stub packages in setup.py Additionally, some modules that we were previously ignoring import failures for now have stubs. So let's use them. The rest of this change consists of fixups to make the newer mypy + stubs pass CI. Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Add missing type hints to non-client REST servlets. (#10817)Patrick Cloke2021-09-151-1/+1
| | | | Including admin, consent, key, synapse, and media. All REST servlets (the synapse.rest module) now require typed method definitions.
* Fix /upload 500'ing when presented a very large image (#10029)Michael Telatynski2021-05-211-0/+9
| | | | | | | | | | | | * Fix /upload 500'ing when presented a very large image Catch DecompressionBombError and re-raise as ThumbnailErrors * Set PIL's MAX_IMAGE_PIXELS to match homeserver.yaml to get it to bomb out quicker, to load less into memory in the case of super large images * Add changelog entry for 10029
* Remove redundant "coding: utf-8" lines (#9786)Jonathan de Jong2021-04-141-1/+0
| | | | | | | Part of #9744 Removes all redundant `# -*- coding: utf-8 -*-` lines from files, as python 3 automatically reads source code as utf-8 now. `Signed-off-by: Jonathan de Jong <jonathan@automatia.nl>`
* Handle image transparency better when thumbnailing. (#9473)Patrick Cloke2021-03-091-3/+8
| | | | Properly uses RGBA mode for 1- and 8-bit images with transparency (instead of RBG mode).
* Add type hints to media rest resources. (#9093)Patrick Cloke2021-01-151-8/+10
|
* Fix typos in comments.Patrick Cloke2020-09-141-2/+2
|
* Do not error when thumbnailing invalid files (#8236)Patrick Cloke2020-09-091-2/+12
| | | | If a file cannot be thumbnailed for some reason (e.g. the file is empty), then catch the exception and convert it to a reasonable error message for the client.
* Stop sub-classing object (#8249)Patrick Cloke2020-09-041-1/+1
|
* isort 5 compatibility (#7786)Will Hunt2020-07-051-2/+1
| | | The CI appears to use the latest version of isort, which is a problem when isort gets a major version bump. Rather than try to pin the version, I've done the necessary to make isort5 happy with synapse.
* Fix: Pillow error when uploading RGBA image (#3325) (#6241)Filip Štědronský2019-12-021-1/+4
| | | Signed-Off-By: Filip Štědronský <g@regnarg.cz>
* media/thumbnailer: Better quality for 1-bit / 8-bit color palette images (#2142)Robert Swain2019-10-041-3/+11
| | | | | | Pillow will use nearest neighbour as the resampling algorithm if the source image is either 1-bit or a color palette using 8 bits. If we convert to RGB before scaling, we'll probably get a better result.
* Remove unnecessary parentheses around return statements (#5931)Andrew Morgan2019-08-301-2/+2
| | | | | Python will return a tuple whether there are parentheses around the returned values or not. I'm just sick of my editor complaining about this all over the place :)
* Run Black. (#5482)Amber Brown2019-06-201-11/+4
|
* Fix image orientation when generating thumbnail (#5039)PauRE2019-05-161-0/+35
|
* run isortAmber Brown2018-07-091-2/+2
|
* Fix upErik Johnston2017-10-131-10/+3
|
* Fix up thumbnailing functionErik Johnston2017-10-131-3/+10
|
* Copy everything to backupErik Johnston2017-10-121-1/+8
|
* Basic implementation of backup media storeErik Johnston2017-10-121-10/+6
|
* Log which files we saved attachments to in the media_repositoryMark Haines2017-01-101-0/+5
|
* copyrightsMatthew Hodgson2016-01-071-1/+1
|
* bump up image quality a bit more as it looks crapMatthew Hodgson2015-07-141-1/+1
|
* Move rest APIs back under the rest directoryMark Haines2015-01-221-0/+89