# HG changeset patch # User Goffi # Date 1597355159 -7200 # Node ID 15612c0fb42179d86f1f63d8c9dbd3fcf12ceb1b # Parent d49607e3a066ed0f443ff110104eabc289f22c57 plugin XEP-0264: updated size to get values closest to standard one: - sizes used for thumbnails are now matching common resolutions. - added BIG and FULL_SCREEN sizes - sort thumbnails by sizes when parsing them. diff -r d49607e3a066 -r 15612c0fb421 sat/plugins/plugin_comp_file_sharing.py --- a/sat/plugins/plugin_comp_file_sharing.py Mon Aug 03 08:45:49 2020 +0200 +++ b/sat/plugins/plugin_comp_file_sharing.py Thu Aug 13 23:45:59 2020 +0200 @@ -434,7 +434,7 @@ if mime_type is not None and mime_type.startswith("image"): thumbnails = extra.setdefault(C.KEY_THUMBNAILS, []) - for max_thumb_size in (self._t.SIZE_SMALL, self._t.SIZE_MEDIUM): + for max_thumb_size in self._t.SIZES: try: thumb_size, thumb_id = await self._t.generateThumbnail( final_path, diff -r d49607e3a066 -r 15612c0fb421 sat/plugins/plugin_comp_file_sharing_management.py --- a/sat/plugins/plugin_comp_file_sharing_management.py Mon Aug 03 08:45:49 2020 +0200 +++ b/sat/plugins/plugin_comp_file_sharing_management.py Thu Aug 13 23:45:59 2020 +0200 @@ -404,7 +404,7 @@ if media_type == 'image': thumbnails = [] - for max_thumb_size in (self._t.SIZE_SMALL, self._t.SIZE_MEDIUM): + for max_thumb_size in self._t.SIZES: try: thumb_size, thumb_id = yield self._t.generateThumbnail( file_path, diff -r d49607e3a066 -r 15612c0fb421 sat/plugins/plugin_xep_0264.py --- a/sat/plugins/plugin_xep_0264.py Mon Aug 03 08:45:49 2020 +0200 +++ b/sat/plugins/plugin_xep_0264.py Thu Aug 13 23:45:59 2020 +0200 @@ -70,8 +70,11 @@ class XEP_0264(object): - SIZE_SMALL = (250, 250) - SIZE_MEDIUM = (1024, 1024) + SIZE_SMALL = (320, 320) + SIZE_MEDIUM = (640, 640) + SIZE_BIG = (1280, 1280) + SIZE_FULL_SCREEN = (2560, 2560) + SIZES = (SIZE_SMALL, SIZE_MEDIUM, SIZE_FULL_SCREEN) def __init__(self, host): log.info(_("Plugin XEP_0264 initialization")) @@ -108,7 +111,7 @@ height = thumbnail_elt.getAttribute("height") if width and height: try: - thumbnail["size"] = int(width), int(height) + thumbnail["size"] = (int(width), int(height)) except ValueError: pass try: @@ -118,6 +121,8 @@ thumbnails.append(thumbnail) if thumbnails: + # we want thumbnails ordered from smallest to biggest + thumbnails.sort(key=lambda t: t.get('size', (0, 0))) file_data.setdefault("extra", {})[C.KEY_THUMBNAILS] = thumbnails return True