Merge 71c37cf902
into be65a8ec01
This commit is contained in:
commit
63c642e107
|
@ -0,0 +1 @@
|
|||
Thumbnail WebP images as WebP instead of JPEG, preserving transparency.
|
|
@ -286,7 +286,8 @@ Installing prerequisites on Ubuntu or Debian:
|
|||
```sh
|
||||
sudo apt install build-essential python3-dev libffi-dev \
|
||||
python3-pip python3-setuptools sqlite3 \
|
||||
libssl-dev virtualenv libjpeg-dev libxslt1-dev libicu-dev
|
||||
libssl-dev virtualenv libjpeg-dev libxslt1-dev libicu-dev \
|
||||
libwebp-dev
|
||||
```
|
||||
|
||||
##### ArchLinux
|
||||
|
@ -295,7 +296,7 @@ Installing prerequisites on ArchLinux:
|
|||
|
||||
```sh
|
||||
sudo pacman -S base-devel python python-pip \
|
||||
python-setuptools python-virtualenv sqlite3 icu
|
||||
python-setuptools python-virtualenv sqlite3 icu libwebp
|
||||
```
|
||||
|
||||
##### CentOS/Fedora
|
||||
|
@ -306,7 +307,7 @@ Installing prerequisites on CentOS or Fedora Linux:
|
|||
sudo dnf install libtiff-devel libjpeg-devel libzip-devel freetype-devel \
|
||||
libwebp-devel libxml2-devel libxslt-devel libpq-devel \
|
||||
python3-virtualenv libffi-devel openssl-devel python3-devel \
|
||||
libicu-devel
|
||||
libicu-devel libwebp-devel
|
||||
sudo dnf groupinstall "Development Tools"
|
||||
```
|
||||
|
||||
|
@ -326,7 +327,7 @@ Please follow [the official instructions of PyICU](https://pypi.org/project/PyIC
|
|||
|
||||
On ARM-based Macs you may also need to install libjpeg and libpq:
|
||||
```sh
|
||||
brew install jpeg libpq
|
||||
brew install jpeg libpq webp
|
||||
```
|
||||
|
||||
On macOS Catalina (10.15) you may need to explicitly install OpenSSL
|
||||
|
@ -346,7 +347,7 @@ Installing prerequisites on openSUSE:
|
|||
sudo zypper in -t pattern devel_basis
|
||||
sudo zypper in python-pip python-setuptools sqlite3 python-virtualenv \
|
||||
python-devel libffi-devel libopenssl-devel libjpeg62-devel \
|
||||
libicu-devel
|
||||
libicu-devel libwebp-devel
|
||||
```
|
||||
|
||||
##### OpenBSD
|
||||
|
|
|
@ -47,7 +47,7 @@ THUMBNAIL_SIZE_YAML = """\
|
|||
THUMBNAIL_SUPPORTED_MEDIA_FORMAT_MAP = {
|
||||
"image/jpeg": "jpeg",
|
||||
"image/jpg": "jpeg",
|
||||
"image/webp": "jpeg",
|
||||
"image/webp": "webp",
|
||||
# Thumbnails can only be jpeg or png. We choose png thumbnails for gif
|
||||
# because it can have transparency.
|
||||
"image/gif": "png",
|
||||
|
@ -102,6 +102,10 @@ def parse_thumbnail_requirements(
|
|||
requirement.append(
|
||||
ThumbnailRequirement(width, height, method, "image/png")
|
||||
)
|
||||
elif thumbnail_format == "webp":
|
||||
requirement.append(
|
||||
ThumbnailRequirement(width, height, method, "image/webp")
|
||||
)
|
||||
else:
|
||||
raise Exception(
|
||||
"Unknown thumbnail mapping from %s to %s. This is a Synapse problem, please report!"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Copyright 2014-2016 OpenMarket Ltd
|
||||
# Copyright 2020-2021 The Matrix.org Foundation C.I.C.
|
||||
# Copyright 2014-2016,2023 OpenMarket Ltd
|
||||
# Copyright 2020-2021,2023 The Matrix.org Foundation C.I.C.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -40,7 +40,7 @@ class ThumbnailError(Exception):
|
|||
|
||||
|
||||
class Thumbnailer:
|
||||
FORMATS = {"image/jpeg": "JPEG", "image/png": "PNG"}
|
||||
FORMATS = {"image/jpeg": "JPEG", "image/png": "PNG", "image/webp": "WEBP"}
|
||||
|
||||
@staticmethod
|
||||
def set_limits(max_image_pixels: int) -> None:
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright 2014-2016 OpenMarket Ltd
|
||||
# Copyright 2023 The Matrix.org Foundation C.I.C
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -12,7 +13,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from PIL.features import check_codec
|
||||
from PIL.features import check_codec, check_module
|
||||
|
||||
# check for JPEG support.
|
||||
if not check_codec("jpg"):
|
||||
|
@ -27,6 +28,15 @@ if not check_codec("jpg"):
|
|||
if not check_codec("zlib"):
|
||||
raise Exception(
|
||||
"FATAL: zip codec not supported. Install pillow correctly! "
|
||||
" 'sudo apt-get install libjpeg-dev' then 'pip uninstall pillow &&"
|
||||
" 'sudo apt-get install zlib1g-dev' then 'pip uninstall pillow &&"
|
||||
" pip install pillow --user'"
|
||||
)
|
||||
|
||||
|
||||
# check for WebP support.
|
||||
if not check_module("webp"):
|
||||
raise Exception(
|
||||
"FATAL: webp module not supported. Install pillow correctly! "
|
||||
" 'sudo apt-get install libwebp-dev' then 'pip uninstall pillow &&"
|
||||
" pip install pillow --user'"
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue