thumbnail WebP as WebP
Closes: https://github.com/matrix-org/synapse/issues/11840 Signed-off-by: Ronny (tastytea) Gutbrod <tastytea@tastytea.de>pull/14890/head
parent
3d70cc393f
commit
d2f795b87d
|
@ -0,0 +1 @@
|
||||||
|
Thumbnail WebP images as WebP instead of JPEG, preserving transparency.
|
|
@ -47,7 +47,7 @@ THUMBNAIL_SIZE_YAML = """\
|
||||||
THUMBNAIL_SUPPORTED_MEDIA_FORMAT_MAP = {
|
THUMBNAIL_SUPPORTED_MEDIA_FORMAT_MAP = {
|
||||||
"image/jpeg": "jpeg",
|
"image/jpeg": "jpeg",
|
||||||
"image/jpg": "jpeg",
|
"image/jpg": "jpeg",
|
||||||
"image/webp": "jpeg",
|
"image/webp": "webp",
|
||||||
# Thumbnails can only be jpeg or png. We choose png thumbnails for gif
|
# Thumbnails can only be jpeg or png. We choose png thumbnails for gif
|
||||||
# because it can have transparency.
|
# because it can have transparency.
|
||||||
"image/gif": "png",
|
"image/gif": "png",
|
||||||
|
@ -102,6 +102,10 @@ def parse_thumbnail_requirements(
|
||||||
requirement.append(
|
requirement.append(
|
||||||
ThumbnailRequirement(width, height, method, "image/png")
|
ThumbnailRequirement(width, height, method, "image/png")
|
||||||
)
|
)
|
||||||
|
elif thumbnail_format == "webp":
|
||||||
|
requirement.append(
|
||||||
|
ThumbnailRequirement(width, height, method, "image/webp")
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
"Unknown thumbnail mapping from %s to %s. This is a Synapse problem, please report!"
|
"Unknown thumbnail mapping from %s to %s. This is a Synapse problem, please report!"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Copyright 2014-2016 OpenMarket Ltd
|
# Copyright 2014-2016,2023 OpenMarket Ltd
|
||||||
# Copyright 2020-2021 The Matrix.org Foundation C.I.C.
|
# Copyright 2020-2021,2023 The Matrix.org Foundation C.I.C.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -38,7 +38,7 @@ class ThumbnailError(Exception):
|
||||||
|
|
||||||
|
|
||||||
class Thumbnailer:
|
class Thumbnailer:
|
||||||
FORMATS = {"image/jpeg": "JPEG", "image/png": "PNG"}
|
FORMATS = {"image/jpeg": "JPEG", "image/png": "PNG", "image/webp": "WEBP"}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def set_limits(max_image_pixels: int) -> None:
|
def set_limits(max_image_pixels: int) -> None:
|
||||||
|
|
Loading…
Reference in New Issue